Skip to main content

Bug Tracker

Side navigation

#6730 closed bug (invalid)

Opened June 27, 2010 11:23PM UTC

Closed October 03, 2010 10:26PM UTC

$(document).bind( 'ready', fn ) fn never execs if called after dom ready fires.

Reported by: cowboy Owned by:
Priority: undecided Milestone: 1.4.3
Component: event Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

Not a bug, per se.. but should be documented or fixed. Is .bind( 'ready', fn ) even documented? Is this a non-issue?

Here's a working example: http://jsfiddle.net/cowboy/MT3ft/

$(function(){
   log("1. $(fn)");

    $(function(){
        log("2. $(fn) -> $(fn)");
    });
    
    $(document).bind( 'ready', function(){
        // Executes because it is bound before the last
        // DOM ready handler has executed.
        log("3. $(fn) -> $(document).bind( 'ready', fn )");
    });
});

$(document).bind( 'ready', function(){
   log("4. $(document).bind( 'ready', fn )");
    
    $(function(){
        log("5. $(document).bind( 'ready', fn ) -> $(fn)");
    });
    
    $(document).bind( 'ready', function(){
        // Doesn't execute because it is bound while the
        // last DOM ready handler is executing.
        log("6. $(document).bind( 'ready', fn ) -> $(document).bind( 'ready', fn )");
    });
    
    setTimeout( foo, 100 );
});

function foo(){
   log("7. setTimeout");

    $(function(){
        log("8. setTimeout -> $(fn)");
    });
    
    $(document).bind( 'ready', function(){
        // Doesn't execute because it is bound after the
        // last DOM ready handler has executed.
        log("9. setTimeout -> $(document).bind( 'ready', fn )");
    });
};​
​
Attachments (0)
Change History (2)

Changed July 11, 2010 11:46PM UTC by dmethvin comment:1

component: unfiledevent

Changed October 03, 2010 10:26PM UTC by dmethvin comment:2

priority: → undecided
resolution: → invalid
status: newclosed
.bind("ready")
isn't documented. This is probably a good example of why it shouldn't be supported, it would be an exception since you're expecting ready to fire immediately as it's really a binary situation (either the document is already loaded or it isn't).