Menu

#5 new useful function

open
nobody
None
5
2007-10-08
2007-10-08
vinz_fr
No

Hi,

I've been using IEunit for months now, and I must say it's great. I have a problem though, which is linked to the intensive use of ajax: depending on the delay between a click and the server response, I have to set a lot of sleep statements, which make it hard to maintain, and make it fail pretty often. That's why I added a function in IeDhtml.js, which prevents this problem in some cases.

I'm using AjaxAnywhere framework on a lot of pages. It allows to reload only a zone of the page. While reloading the zone, a DIV is displayed saying "loading.." (like in gmail). Instead of using "sleep(5000);", I'm calling the following function:

this.waitWhileVisible=function(id){
this.sleep(1000);
var loadingDiv=this.findObjById(id);
var visibility=loadingDiv.style.getAttribute('display');
//this.log("visibility found: "+visibility);
var i=1;
while(visibility!="none"){
this.log("still waiting ("+i+" time(s)), visibility='"+visibility+"'.");
this.sleep(1000);
visibility=loadingDiv.style.getAttribute('display');
i++;
}
loadingDiv=null;
visibility=null;
i=null;
}

You might need to tune this to match your needs, but basically, while the DOM element with the given ID has a display value different than "none", it waits one more second.

Hope this helps !

--
Vincent FUCHS

Discussion


Log in to post a comment.