Opened 13 years ago
Closed 12 years ago
#6730 closed bug (invalid)
$(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 )"); }); }; }}}
Change History (2)
comment:1 Changed 13 years ago by
Component: | unfiled → event |
---|
comment:2 Changed 12 years ago by
Priority: | → undecided |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
.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).