PDA

View Full Version : Ext.require() not working



dlewington
22 May 2013, 2:49 AM
I use Ext.require() to load numerous extjs library files, when all files are loaded that callback function in require() is executed, but when i try to load my custom defined namespaces eg "MyApp.custom.DoSeomthing" script is loaded but callback is not fired.
I assume any JS file we create should have a particular structure to make a callback request to calling function, how should I write, otherwise there is no way to know by calling function if script is properly loaded, thats why $.getScript() is said to be unreliable.
here is my sample js file

Ext.define('Environment', { extend: 'Ext.data.Model', fields: [ 'EnvName', 'Descr', 'EnvVer', 'Creator', 'Created' ]});

slemmon
23 May 2013, 2:44 PM
I just tried with require() including Ext lib files and some I put ad hoc in a directory for testing (also linked to it in my loader's path config so that the namespace'd classes would know where to look) and both the lib and custom class files were imported and the callback called.

In my test I was testing with 4.2.1 (just out today). What ExtJS version are you using?

dlewington
24 May 2013, 3:05 AM
Thanks slemmon :-)

We are on extjs 4.2

we can also load custom JS files, but its not reliable. Have a look at the below code which is in all.js files

$.getScript(Ext.Loader.getPath('Layout.Layout2'), function(){ <------------------------(1)
Ext.require([
'Ext.ux.grid.filter.BooleanFilter',
'Ext.ux.grid.filter.DateFilter',
'Ext.ux.grid.filter.DateTimeFilter',
'Ext.ux.grid.filter.Filter',
'Ext.ux.grid.filter.ListFilter',
'Ext.ux.grid.filter.NumericFilter',
'Ext.ux.grid.filter.StringFilter',
'Ext.ux.grid.FiltersFeature',
'Column.custom.grid.DataTable' <------------------------------- (2)
], function() {
Ext.getCmp("contentPane").setLoading(false);
render();
});
});

Here we loaded 'Column.custom.grid.DataTable' it works, but I didnít load " Layout.Layout2" in a useful manner thatís why I had to move it to $.getScript() otherwise why would I need to add $.getScript()

dlewington
24 May 2013, 3:06 AM
I just tried with require() including Ext lib files and some I put ad hoc in a directory for testing (also linked to it in my loader's path config so that the namespace'd classes would know where to look) and both the lib and custom class files were imported and the callback called.

In my test I was testing with 4.2.1 (just out today). What ExtJS version are you using?

Thanks slemmon :-)

We are on extjs 4.2

we can also load custom JS files, but its not reliable. Have a look at the below code which is in all.js files

$.getScript(Ext.Loader.getPath('Layout.Layout2'), function(){ <------------------------(1)
Ext.require([
'Ext.ux.grid.filter.BooleanFilter',
'Ext.ux.grid.filter.DateFilter',
'Ext.ux.grid.filter.DateTimeFilter',
'Ext.ux.grid.filter.Filter',
'Ext.ux.grid.filter.ListFilter',
'Ext.ux.grid.filter.NumericFilter',
'Ext.ux.grid.filter.StringFilter',
'Ext.ux.grid.FiltersFeature',
'Column.custom.grid.DataTable' <------------------------------- (2)
], function() {
Ext.getCmp("contentPane").setLoading(false);
render();
});
});

Here we loaded 'Column.custom.grid.DataTable' it works, but I didnít load " Layout.Layout2" in a useful manner thatís why I had to move it to $.getScript() otherwise why would I need to add $.getScript()

slemmon
28 May 2013, 4:17 PM
What does your loader's setConfig() param look like? Is it setting the path for the "Column" namespace and the "Layout" namespace?