Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. function AjaxLoaded() {
  2. $('document').trigger('ready');
  3. }
  4.  
  5. <script>
  6. // easy copy of an array
  7. Array.prototype.copy = function() {
  8. return [].concat(this);
  9. };
  10.  
  11. // this function is added to jQuery, it allows access to the readylist
  12. // it works for jQuery 1.3.2, it might break on future versions
  13. $.getReadyList = function() {
  14. if(this.readyList != null)
  15. this.myreadylist = this.readyList.copy();
  16. return this.myreadylist;
  17. };
  18.  
  19. $(document).ready(function() {
  20. alert("blah");
  21. });
  22.  
  23. </script>
  24.  
  25. <script>
  26.  
  27. // this should be added last so it gets all the ready event
  28. $(document).ready(function() {
  29. readylist = $.getReadyList();
  30. });
  31.  
  32. </script>
  33.  
  34. <input type="button" onclick="$(readylist).each(function(){this();});" value="trigger ready" />
  35.  
  36. function AjaxLoaded() {
  37. $(document).trigger('ready');
  38. }
  39.  
  40. // Overrides jQuery-ready and makes it triggerable with $.triggerReady
  41. // This script needs to be included before other scripts using the jQuery-ready.
  42. // Tested with jQuery 1.7
  43. (function(){
  44. var readyList = [];
  45.  
  46. // Store a reference to the original ready method.
  47. var originalReadyMethod = jQuery.fn.ready;
  48.  
  49. // Override jQuery.fn.ready
  50. jQuery.fn.ready = function(){
  51. if(arguments.length && arguments.length > 0 && typeof arguments[0] === 'function') {
  52. readyList.push(arguments[0]);
  53. }
  54.  
  55. // Execute the original method.
  56. originalReadyMethod.apply( this, arguments );
  57. };
  58.  
  59. // Used to trigger all ready events
  60. $.triggerReady = function() {
  61. $(readyList).each(function(){this();});
  62. };
  63. })();
  64.  
  65. // jquery_trigger_ready.js
  66. // this function is added to jQuery, it allows access to the readylist
  67. // it works for jQuery 1.3.2, it might break on future versions
  68. $.getReadyList = function() {
  69. if(this.readyList != null) { this.myreadylist = [].concat(this.readyList); }
  70. return this.myreadylist;
  71. };
  72.  
  73. $(document).ready(function() {
  74. readylist = $.getReadyList();
  75. });
  76.  
  77. $.triggerReady = function() {
  78. $(readylist).each(function(){this();});
  79. }
  80.  
  81. <html>
  82. <head>
  83. <title>trigger ready event</title>
  84. <script src="test2_files/jquery-1.js" type="text/javascript"></script>
  85. <script src="jquery_trigger_ready.js" type="text/javascript"></script>
  86. </head>
  87. <body>
  88. <input onclick="$.triggerReady();" value="trigger ready" type="button">
  89. <script type="text/javascript">
  90. $(document).ready(function(){
  91. alert("blah");
  92. });
  93. </script>
  94. </body>
  95. </html>
  96.  
  97. $(document).ready(function () {
  98. $('.specialClass').click(....
  99.  
  100. $(document).bind('ready', function(event) {
  101. $('.specialClass', event.target).click(..
  102.  
  103. loadedDiv.trigger('ready')
  104.  
  105. jQuery.fn.loadExtended = function(url,completeCallback){
  106. return this.load(url,function(responseText, textStatus, XMLHttpRequest) {
  107. if (completeCallback !== undefined && completeCallback !== null) {
  108. completeCallback(responseText, textStatus, XMLHttpRequest);
  109. }
  110. $(this).trigger("ready");
  111. });
  112. };
  113.  
  114. $(".container").load(url,function(responseText, textStatus, XMLHttpRequest) {
  115. $(this).trigger("ready");
  116. });
  117.  
  118. $(".container").loadExtended("tag_cloud.html");
  119.  
  120. $(".container").loadExtended("tag_cloud.html",function(){
  121. alert('callback function')
  122. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement