Skip to content

Commit

Permalink
When adding robust $.include and ajax functionality I needed to be ab…
Browse files Browse the repository at this point in the history
…le to delays execution of ready(fn) functions 1) while requested includes were still loading and 2) while new ajax content (and related includes) were still loading. This required extending ready() to add extra ready conditions, but 1.4.2 had some issues that prevented this from being possible.


I made minor fixes in 4 places that will have no impact on working code, but will allow this type of improvement in the future. Comments marked MYEDIT explain exactly what and why.
  • Loading branch information
johncrenshaw authored and johncrenshaw committed Jul 5, 2010
1 parent 0bbbe5f commit 8491f22
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions jquery-1.4.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ jQuery.extend({

// Is the DOM ready to be used? Set to true once it occurs.
isReady: false,

// MYEDIT: stub so that ready can be extended without having
// to be rebound to load events (load events point here rather
// than directly at ready())
_onReady: function() {jQuery.ready();},

// Handle when the DOM is ready
ready: function() {
Expand All @@ -393,7 +398,7 @@ jQuery.extend({
}

// Reset the list of functions
readyList = null;
readyList = []; // MYEDIT: setting to "null" prevents anything from being added to the list again. This becomes a problem if you try to implement ajax includes.
}

// Trigger any bound ready events
Expand Down Expand Up @@ -422,7 +427,7 @@ jQuery.extend({
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );

// A fallback to window.onload, that will always work
window.addEventListener( "load", jQuery.ready, false );
window.addEventListener( "load", jQuery._onReady, false ); // MYEDIT: use stub so ready() can be extended easily

// If IE event model is used
} else if ( document.attachEvent ) {
Expand All @@ -431,7 +436,7 @@ jQuery.extend({
document.attachEvent("onreadystatechange", DOMContentLoaded);

// A fallback to window.onload, that will always work
window.attachEvent( "onload", jQuery.ready );
window.attachEvent( "onload", jQuery._onReady ); // MYEDIT: use stub so ready() can be extended easily

// If IE and not a frame
// continually check to see if the document is ready
Expand Down

2 comments on commit 8491f22

@jzaefferer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should fork jQuery core, not jQuery UI for any core related changes.

@johncrenshaw
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aw, man. I knew I was going to make a mistake like that somewhere. The instructions I was following were for contributing a change to jquery-ui, and I was trying to adapt them. I'll do the core fork. Sorry.

Please sign in to comment.