Reputation: 199
Is there an easier way to wait for an element to load ( by independant script/mootools/other ). For example:
I am waiting for a google map to load, but I don't want to use its API for checks. So I made two functions:
function checkIfexist() {
if(jQuery('#container').length)
return 0;
else
reload(1);
}
function reload(mode) {
setTimeout(function(){
do stuff
.
.
.
if(mode==1)
checkIfexist();
}, 400);
}
I am starting it with reload(1);
Is there an easier way to use setTimeout in such a way? I don't want to use delay, wait or whatever.
Upvotes: 0
Views: 307
Reputation: 22261
.ajaxStop()
fires when all concurrent ajax requests have finished, so you can just use it directly, for example:
$(function(){
$(document).ajaxStop(function() {
// all ajax is done
});
});
Upvotes: 1