jquery - What happens if you call $(document).ready after the dom has loaded? -


i'm debugging code (that did not write) , javascript pulled page after initial dom.ready call via ajax request contains:

$(document).on('ready', function(){     $('#input1').attr('data-defaultvalue',123); }); 

am right in thinking code inside function never fire waiting event has happened.

there $(document).on( "ready", handler ), deprecated of jquery 1.8. behaves ready method if ready event has fired , try .on( "ready" ) bound handler not executed. ready handlers bound way executed after bound other 3 methods above.

source

you can test code pretty easily. .ready fire, .on('ready'... not.

settimeout(function() {     $(document).ready(function() {          alert(".ready");     });     $(document).on('ready', function() {          alert(".on('ready')");     }); }, 5000); 

http://jsfiddle.net/n65leobh/


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -