Use load callback
$("#tempMain").load($(this).attr("href"),function(){
resizeDivs();
// do other stuff load is completed
});
with jquery
function waitForElement(elementPath, callBack){
window.setTimeout(function(){
if($(elementPath).length){
callBack(elementPath, $(elementPath));
}else{
waitForElement(elementPath, callBack);
}
},500)
}
e.g. to use:
waitForElement("#myDiv",function(){
console.log("done");
});
here is without jquery
function waitForElement(elementId, callBack){
window.setTimeout(function(){
var element = document.getElementById(elementId);
if(element){
callBack(elementId, element);
}else{
waitForElement(elementId, callBack);
}
},500)
}
e.g. to use:
waitForElement("yourId",function(){
console.log("done");
});
You can attach a callback in the jQuery load
function :
$("#tempMain").load($(this).attr("href"), resizeDivs);
see : http://api.jquery.com/load/