aconran
20 Jun 2007, 11:40 AM
I discovered a bug today where I was trying to delay the loading of a singleton by a few seconds using the delay option of Ext.EventManager.onDocumentReady
Ext.EventManager.onDocumentReady(MySingleton.init, MySingleton, {delay: 3000});
I have a single page application and this singleton can be loaded in 2 ways. It can be loaded by refreshing the browser OR it can be loaded after logging into my application.
In the later scenario it is loaded by an UpdateManager with scripts set to true.
Ext.EventManager.onDocumentReady simply runs the function without paying any attention to the options if the doc's ready state is already set.
onDocumentReady : function(fn, scope, options){
if(docReadyState){ // if it already fired
fn.call(scope || window, scope);
return;
}
Until the real fix comes out which supports all options I am using the following code which solves my problem.
if(docReadyState){
if (options && options.delay) {
fn.defer(options.delay, scope || window);
} else {
fn.call(scope || window, scope);
}
return;
}
Ext.EventManager.onDocumentReady(MySingleton.init, MySingleton, {delay: 3000});
I have a single page application and this singleton can be loaded in 2 ways. It can be loaded by refreshing the browser OR it can be loaded after logging into my application.
In the later scenario it is loaded by an UpdateManager with scripts set to true.
Ext.EventManager.onDocumentReady simply runs the function without paying any attention to the options if the doc's ready state is already set.
onDocumentReady : function(fn, scope, options){
if(docReadyState){ // if it already fired
fn.call(scope || window, scope);
return;
}
Until the real fix comes out which supports all options I am using the following code which solves my problem.
if(docReadyState){
if (options && options.delay) {
fn.defer(options.delay, scope || window);
} else {
fn.call(scope || window, scope);
}
return;
}