Skip to content

Commit

Permalink
Ticket 6844. Ability to delay the ready event.
Browse files Browse the repository at this point in the history
  • Loading branch information
InfinitiesLoop committed Jul 28, 2010
1 parent 1650672 commit 7a98b55
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/core.js
Expand Up @@ -46,6 +46,9 @@ var jQuery = function( selector, context ) {

// The functions to execute on DOM ready
readyList = [],

// Counts how many ready holds are active
readyHold = 0,

// The ready event handler
DOMContentLoaded,
Expand Down Expand Up @@ -360,9 +363,20 @@ jQuery.extend({
isReady: false,

// Handle when the DOM is ready
ready: function() {
ready: function(state) {
// Make sure that the DOM is not already loaded
if ( !jQuery.isReady ) {
if ( typeof state === "boolean" ) {
// plugin is delaying or undelaying the ready event
if ( state ) {
readyHold--;
} else {
readyHold++;
}
}
if ( readyHold > 0 ) {
return;
}
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
if ( !document.body ) {
return setTimeout( jQuery.ready, 13 );
Expand Down

0 comments on commit 7a98b55

Please sign in to comment.