Hybrid View
-
23 Jul 2012 7:27 PM #1
[ExtJS 4.1.1] Ext.require does not call callback if provided
[ExtJS 4.1.1] Ext.require does not call callback if provided
If I pass a callback fn to Ext.require, it never gets called. For example, Ext.require('Sjs.apps.examples.reference.Main', function() { console.log('loaded'); });
This problem appeared in 4.1.0 and is critical to the proper functioning of our environment. This is blocking us from upgrading from 4.0.7.
-
23 Jul 2012 7:45 PM #2
Works ok for me:
I tried it with ext-all.js and also dynamic loading against 4.1.1, the log fires in both cases.Code:Ext.require('Ext.panel.Panel', function(){ console.log('Foo'); });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
24 Jul 2012 10:43 AM #3
Ok, well I'll have to do more digging and see if I can create an example to show the problem. In our environment, we define application classes that extend Ext.app.Application, and when an app is required on the page, Ext.require is called, passing the app class name and a callback. 100% of the time, the callback never gets called because of this line in Loader.js:
syncModeEnabled is always false. The callback never gets called.Code:if (syncModeEnabled) { callback.call(scope); ...
By the way, I'm using ext-dev.js. Also, the code I am using that doesn't work in 4.1.1, works fine in 4.0.5.
-
24 Jul 2012 11:06 AM #4
Interestingly, if I call Ext.syncRequire(someClass, callback), then ALL the callbacks that never got called from previous Ext.require calls suddenly get invoked. Then I get a "field is undefined" exception on Model.js.
It is difficult to create a standalone example outside of our environment, but I'll see what I can do. But something has definitely changed with the Loader since 4.0.5.
-
24 Jul 2012 2:01 PM #5
Here's a big clue:
When our main page loads, we wind up in a state where Ext.Loader.numPendingFiles == 4. The pending files turn out to be the scripts for the classes Ext.LoadMask, Ext.Ajax, Ext.data.Store and Ext.data.AbstractStore.
Coincidentally, in the Ext.Loader.loadScriptFile method, there is this code:
If I write the url to the console at this point, guess what files I see?Code:if (isFileLoaded[url]) { return Loader; }
Having that check in loadScriptFile prevents the onLoad handler from getting called. This check was not present in 4.0.5. The expectation is that the onLoad handler should always get called, even if the file is already loaded. That's not happening.Code:http://hom-bhubbard3/assets/scripts/deploy/ext-live/src/data/AbstractStore.js already loaded http://hom-bhubbard3/assets/scripts/deploy/ext-live/src/data/Store.js already loaded http://hom-bhubbard3/assets/scripts/deploy/ext-live/src/Ajax.js already loaded http://hom-bhubbard3/assets/scripts/deploy/ext-live/src/LoadMask.js already loaded
-
24 Jul 2012 3:16 PM #6
I still see the callback fired:
Code:Ext.require('Ext.panel.Panel'); Ext.onReady(function() { Ext.require('Ext.panel.Panel', function(){ console.log('loaded'); }); });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.


Reply With Quote