PDA

View Full Version : Extjs.application, Ext.require, Ext.Loader - no automatic loading, with Ext.require



webxells
29 Jun 2012, 11:59 AM
The problem:

Ext.application loads all controllers, automaticly, as long if the controller have no 'requires' or 'uses' property. Or a Ext.require is given before running the Ext.application code. As long the Ext.application runs without requires, all controller runs their 'init' functions. After given a 'require' it will never run this.

For example:


Ext.Loader.setConfig({
enabled:true,
paths:{
Editor:'app'
}
});

Ext.application({
name:'AppName',
appFolder:'app',
autoCreateViewport:false,
controllers:['MyController'],
launch:function () {
console.log('Launch App');
}
});



Runs the MyController init function. But if I do this:


Ext.Loader.setConfig({
enabled:true,
paths:{
Editor:'app'
}
});

Ext.require('Load.SomethingElse');

Ext.application({
name:'AppName',
appFolder:'app',
autoCreateViewport:false,
controllers:['MyController'],
launch:function () {
console.log('Launch App');
}
});



The controller is not running, even the launch function will not run. What is the problem, and how can I fix this? I don't understand why here is a mistake, should it not be possible to load any extra stuff manual - if I want to - and load everything else like expected automaticly? Thanks for help (PS: I studied the http://www.sencha.com/blog/using-ext-loader-for-your-application/ but it was not helpful in this manner).

Izhaki
29 Jun 2012, 4:53 PM
Try and put your loader code and the require within the Ext.onReady event:




Ext.onReady(function() {
Ext.Loader.setConfig({enabled:true});
});

webxells
2 Jul 2012, 1:19 AM
This sound too good to be true, but it didn't help.
When I use requires : ['load.me.something'] in the Controller, no init function (controller) or launch (application) will be triggered. But the thing was definitely loaded.

THE SOLUTION: I uses a wrong namespace, the file was loaded correctly, but the namespace in the define part was'nt correct. Finding the bug was very hard.

friend
2 Jul 2012, 4:09 AM
I've been bitten by this same problem. Also, if you copy/paste a store or model and forget to change the defined class name, you'll also get a big, pretty, white, blank page and no error message/stack trace.

This REALLY needs to be addressed...