I want to use jQuery ready()
function for the document element. Here are my scripts:
1st page:
$(document).ready(function(){
$('form#haberekle').ajaxForm(options);
});
2nd page:
$(document).ready(function() {
var options = {
success:showResponse,
beforeSubmit:showRequest,
resetForm:true
};
$('#haberresmiekleform').ajaxForm(options);
});
These two pages are included in the same main page with <!--#include file=""-->
Can these two functions work properly, or they block each other? According to my experience they seem work properly.
For example: an onclick
function of a button is only one.
You can have as many .ready()
calls as you want, jQuery is designed with this in mind and it's absolutely ok.
So yes, it is ok, and you won't have any problems...this happens all the time.
Think of it as an event handler, like .click()
, this is exactly how it behaves (well, strictly speaking, not exactly, but for most purposes like this). So you can have as many as you want.
One more note that may be of interest, the handlers you pass into .ready()
are pushed via .done()
to the readyList
, which means they'll execute in the order you called them in the page. The same order behavior is true (though via an array, a different method) in earlier versions of jQuery.
Yes, that is fine. Both will be called when the dom is fully loaded. Note that if you call .ready()
after the dom is already loaded, the callback will be executed immediately. See http://api.jquery.com/ready/
Yes, you can.
Take a look here: http://www.learningjquery.com/2006/09/multiple-document-ready
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With