New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#7279 - .bind("ready") events fire out of order #80
Conversation
…ll now execute (and unbind) immediately if jQuery.isReady is true
…if possible. This ensures that ready event handlers execute in the proper order, regardless of how they are bound. Handlers bound via jQuery(document).bind( 'ready', fn ) will still have the event object passed in, while handlers bound via jQuery( fn ) and jQuery(document).ready( fn ) will still have a reference to jQuery passed in.
…to pass in a proper jQuery event object in the case of jQuery(document).bind( 'ready', fn ) being called after DOM ready. This solution can't be as full-featured as if trigger were called, but it should work well enough until the whole DOM ready sub-structure can be re-written.
BTW, I consider this a temporary fix. I really think that the DOM ready event system should really get an overhaul to avoid issues like these in the future.. but I don't know that the overall behavior (which my changes address) needs to wait until 1.5. |
Ben, the ready code is most likely being replaced by the Deferreds implementation from jaubourg, so all of this is getting an overhaul. From the discussion in the ticket and the code it seems like the two major issues were that some handlers were firing multiple times (fixed in DOM0 already) and also that handlers fired out of the order they were attached. Anything else? |
The big issues I had were that:
|
Ben, I suspect several of these issues are already resolved in 1.5.2, but can you review and see what might be left? I'm trying to figure out if #7279 should be closed or not. |
Added a replacement pull #293, killing this one. |
My changes fix the issue described in this ticket. Here's an updated JSFiddle using my local build.
I basically check to see if the bind subsystem exists, and if it does, use
rootjQuery.bind( "ready", fn )
otherwise just usereadyList.push( fn )
.I also added a bunch of unit tests, so if nothing else you should grab those.
Hope this helps!