Thursday, November 12, 2009

Use setInterval, clearInterval in CRM 3/4

Using setInterval if very helpful and powerfull when develop javascript in CRM 3/4.

Special target is to load forms very fast and make other code after user start to work.

This example contain two functions.
loadMyPage() and afterLoading()

function loadMyPage() call to function afterLoading() with interval of one second.

After second function afterLoading() is working..

Don’t forget to make the clearInterval.. clear calling.

function afterLoading() {
window.clearInterval(common_init_interval);
}

function loadMyPage(){
common_init_interval = setInterval('try { afterLoading (); } catch (e) { }', 1000);
}


Enjoy,
Rami Heleg