PDA

View Full Version : Configure Ext.Loader.setPath to support wildcards



WidowMaker
25 Feb 2012, 11:20 AM
Hello

I have a huge file (aprox 20,000 lines). It contains many declarations like:

Ext.define('SP.form.BaseButton', {extend:'Ext.Button',
...
});
Ext.define('SP.ui.BaseIcon', {extend:'Ext.Component',
...
});
Ext.Loader:

Ext.Loader.setPath({'SP.form':'huge_file.js'});
The problem is when trying to use Ext.Loader it looks for "huge_file.js/BaseIcon.js", and ofcourse fails.

The problem can be solved with:


splitting this huge file and use separate file for each class but this is not acceptible (at least for now)
adding line Ext.Loader.setPath({'SP.form.BaseButton':'huge_file.js'}) above every class definition.


is there any better workaround? like wildcards in Ext.require?

upd.:
vietits, the huge_file.js loads ok, but Ext.create still looking for huge_file.js/WidgetName.js when see 'SP.form.WidgetName'

vietits
25 Feb 2012, 4:28 PM
1. The first solution is add a SCRIPT tag in your index.html file with its src points to your huge_file.js.

2. The second solution is create a fake class and then load this fake class with Ext.require(). Ex:

a. Create a fake class suppose it is SP.AllClasses


Ext.define('SP.AllClasses', {}); // fake class

// include all your definition of classes here
Ext.define('SP.form.BaseButton',{...});
Ext.define('SP.ui.BaseIcon',{...});
...


b. Load SP.AllClasses


Ext.require('SP.AllClasses');
...

Of course, you have to set path points to your AllClasses.js


Ext.Loader.setPath({'SP':'path to your AllClasses.js'});