PDA

View Full Version : newb question #231 : How to use Ext.require



dedoz
10 Feb 2012, 12:15 PM
without Ext.require first, to check doesnt throw any error/warning


// works ------------------------------------------------
Ext.define('MUI.model.per', {
extend: 'Ext.data.Model',
fields: ['id','name']
});
Ext.create('MUI.model.per');


using sync require


// sync require : doesnt work ------------------------------------------------
Ext.Loader.setPath('MUI','app');
Ext.syncRequire(['MUI.model.per']);
per = Ext.create('MUI.model.per');
// says : Ext.Loader is not enabled, so dependencies cannot be resolved dynamically......
// Missing MUI.model.per
// But i dont need enable dinamyc loading, im loading the class first.


using async require


// async require : doesnt work ------------------------------------------------
// using callback function when finish loading classes
Ext.Loader.setPath('MUI','app');
Ext.require(['MUI.model.per'],
function() {
per = Ext.create('MUI.model.per');
// says : Ext.Loader is not enabled, so dependencies cannot be resolved dynamically.....
// Missing MUI.model.per
// same , i dont need enable dinamyc loading, im loading the class first.
}
);


So how can i use Ext.require?

( test using Ext 4.07 - 4.1 pr1 - 4.1 beta 1 in firefox 10, chrome 17 )

ErnestoR
10 Feb 2012, 12:50 PM
Your missing


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

This enables Ext.Loader to load your files dynamically

dedoz
10 Feb 2012, 1:00 PM
thanks for answerin but i think u didnt read
"i dont need enable dinamyc loading, im loading the class first" in comments, thats the point using ext.require

so i did that and enabled the loader, and now Ext.require() works, but in docs says
--------
enabled (http://www.sencha.com/forum/#!/api/Ext.Loader-cfg-enabled) : Boolean (http://www.sencha.com/forum/#!/api/Boolean)

Whether or not to enable the dynamic dependency loading feature.

Defaults to: false
--------

shouldnt this say just "enable loader functionalities" ? its seems without enable:true, Ext.Loader does nothing, is not just the dymanic dependency feature