PDA

View Full Version : class loader problems



putty
10 Jun 2013, 10:45 PM
Hi, i'm having a little problem with the class loader. My application launches from a URL www.website.com/account/. The application directory with all the js files is located in the web root. The problem is whenever I navigate to www.website.com/account/ the class loader keeps trying to get files from www.website.com/account/application/{path to class}.js instead of www.website.com/application/{path to class}.js


I have updated the paths in the loader config however it doesn't seem to make any difference.



Ext.Loader.setConfig({
enabled: true,
paths: {
MyApp: '../'
}
});


What am I doing wrong?


Note: The documentation say the path is relative to the current HTML file, I don't think this is correct, I think it is relative to the url. I am using apache to rewrite all urls to the root index.php then letting the controller make a decision as to what view to load. This means that my current html path should be the web root (./) however it appears that EXTJS thinks it is ./account/ Am I miss understanding this?

Songle
11 Jun 2013, 12:34 AM
I set my path a little differently to this. In index.js (called by index.html)



Ext.Loader.setConfig({
enabled : true
});
Ext.Loader.setPath('Songle','app');


and the app folder is in the same directory that this file is in.

Hope this helps.

slemmon
12 Jun 2013, 4:32 PM
Is MyApp the name of your application or of some other namespaced, shared files?

putty
13 Jun 2013, 7:12 PM
I'm still currently using MyApp. An example of a namespace would be "MyApp.view. Client"

putty
13 Jun 2013, 7:17 PM
I have tried using Ext.Loader.setPath('MyApp','../'); it doesn't doesn't seem to work either.

I can do something like this. However I still get funny include paths.



Ext.Loader.setConfig({
enabled: true,
paths: {
MyApp.view: '../view',
MyApp.model: '../model',
...
}
});


I set my path a little differently to this. In index.js (called by index.html)



Ext.Loader.setConfig({
enabled : true
});
Ext.Loader.setPath('Songle','app');


and the app folder is in the same directory that this file is in.

Hope this helps.

slemmon
14 Jun 2013, 12:27 PM
If MyApp is the name of your application then you shouldn't need to do any path setting specifically beyond the application's name and appFolder configs.

If your application's name is 'MyApp' and your appFolder is 'app' then MyApp.view.#### will amp to your application's root folder / app / view / ####.js when loading that class.

If MyApp is a separate namespaced set of classes then you would need to set the paths for that namespace, but just the root. Each of the subsequent folders under that will then just correspond to your classes' names.

Is MyApp the name of your application or of some other namespaced, shared files?