PDA

View Full Version : Problem in IE6+ when loading Ext-all.js using ondemand javascript


ksachdeva
08-03-2007, 03:38 PM
Versions of ExtJS that can be used to reproduce the problem : 1.0.1 & 1.1.

A test HTML file is attached which you can put in examples\test directory in your local ExtJS to reproduce the problem.

Story:
I was still using 1.0 till yesterday and things were ok with me. I switched to ExtJS 1.1 and suddenly my app would not work in IE (6 as well as 7). It works fine in Firefox. Here is the code which creates the problem:

var initDocReady = function(){
docReadyEvent = new Ext.util.Event();
if(Ext.isGecko || Ext.isOpera) {
document.addEventListener("DOMContentLoaded", fireDocReady, false);
}else if(Ext.isIE){

document.write("<s"+'cript id="ie-deferred-loader" defer="defer" src="/'+'/:"></s'+"cript>");
var defer = document.getElementById("ie-deferred-loader");

// PROBLEM IS THAT VARIABLE defer IS "null" if I use on-demand javascript to fetch
// ext-all.js


defer.onreadystatechange = function(){
if(this.readyState == "complete"){
fireDocReady();
defer.onreadystatechange = null;
defer.parentNode.removeChild(defer);
}
};
}else if(Ext.isSafari){
docReadyProcId = setInterval(function(){
var rs = document.readyState;
if(rs == "complete") {
fireDocReady();
}
}, 10);
}

E.on(window, "load", fireDocReady);
};


Since it was working fine I went back and compared this snippet with the one in 1.0 and there was indeed a little difference; Here is the old code for IE in initDocReady which works fine:

if(Ext.isIE){

document.write("<s"+'cript id="ie-deferred-loader" defer="defer" src="/'+'/:"></s'+"cript>");

E.on("ie-deferred-loader", "readystatechange", function(){
if(this.readyState == "complete"){
fireDocReady();
}
});
}

Would appreciate the guidance on this.

Regards & thanks
Kapil

jack.slocum
08-03-2007, 08:52 PM
Loading the ext-core "on demand" is not supported. The only way you would be able to make it work is by modifying that code (onReady processing) to run immediately and never go to that block.

I would recommend if you are going to load pieces "on demand", to include ext-core and load the other things you need "on demand".

ksachdeva
08-04-2007, 07:45 AM
But if I put back the code from 1.0 (although I do not understand the differences) things work for me. I am trying to use extjs in a bookmarklet hence have to load entire ext-all.js on-demand.

What would I loose if I modify initDocReady in 1.1 and change it to that in 1.0 (only for IE) ?

Regards
Kapil

jack.slocum
08-04-2007, 03:48 PM
The it won't fire "onload" instead of the intended purpose (before everything is loaded, dom is ready).

tirams
08-15-2007, 04:45 PM
Loading the ext-core "on demand" is not supported. The only way you would be able to make it work is by modifying that code (onReady processing) to run immediately and never go to that block.

I would recommend if you are going to load pieces "on demand", to include ext-core and load the other things you need "on demand".

I'm trying to follow this recommendation so I can load ext-all in the background. Is it possible to include ext-core.js then lazy load "on demand" ext-all.js?

Is there a way to use the ext js builder to get a js that has everything but ext-core.js? I'm trying to lazy load prototype.js as well. Does ext-core.js need the adapter and prototype.js to be included?

Has anyone gotten lazy load of Ext to work?

thanks for any info and for a great product Jack.