PDA

View Full Version : Ext.class.requires won't load classes from a correct path



feiichi
7 Sep 2013, 10:33 AM
Hello,

I have lots of custom classes in my Ext JS project and they are all - let's say - in the "my_custom_classes/" directory and use "My." namespace. The namespace and the path are being picked up correctly by the bootstrap.js, so there is an entry like this:
"My": "my_custom_classes/".

When I require a custom class via Ext.require at the beginning of the app.js file, it works. When I use the "requires:" config attribute in the Ext.define block (without prior require via the Ext.require method), it tries to load the classes from a path relative to the "app/" directory. I haven't been able to figure out why it doesn't use the loader path.

Is there anything I am missing on how the Ext.class.requires should work? Thank you!

halcwb
7 Sep 2013, 11:39 PM
Just a quick sanity check, you did enable the loader?



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

ettavolt
9 Sep 2013, 12:08 AM
If you use Ext.app.Aplication, it will override namespace path. Either configure it with appPath:Ext.Loader.getPath('my') or "paths processed":true.

feiichi
10 Sep 2013, 12:02 AM
Thank you for your responses!

I settled this with using the "overrides" folder (my custom classes are overrides or extends for the most parts) - then I don't have to require the classes one by one, although I must manually require any custom class that extends another custom class.

The "overrides" folder, as it often happens to be with ext, isn't loaded automatically though because of a bug. I had to do some tweaks in the app and in the sencha cmd source:

http://www.sencha.com/forum/showthread.php?261361-Properly-using-the-overrides-folder-generated-by-Sencha-Cmd-for-Ext-Js-4.2/page2