PDA

View Full Version : loader not working for a custom path



adeelmahmood
27 Jul 2012, 1:35 PM
for my application the html file that includes the extjs and app.js files is in a completely different folder than the folder where all the js files includes app.js file is in. so to make the dynamic loader work i have tried specifying the custom path



Ext.Loader.setConfig({
enabled : true,
paths : {
DT : "http://servername/path/to/js/folder/extjs-4.1.1/apps/dt"
}
});


Ext.application({
name: 'DT',
appFolder: 'app',

requires: ['DT.view.user.List'],

launch: function(){
console.log('application started');
Ext.create("Ext.container.Viewport", {
layout: "fit",
items: [
{
xtype: 'userlist'
}
]
});
}
});


this doesnt seems to work .. it still tries to load the user.list view file relative to the html file and not the custom path specified above.

Any ideas.

scottmartin
27 Jul 2012, 1:48 PM
Is this a local path? What is the reason for this approach?

Scott.

adeelmahmood
27 Jul 2012, 5:36 PM
its not the preferred approach but its the limitation of the environment I am working in .. html files with server side code embedded in them are served from a different directory and all javascript files are supposed to be in a different directory .. they are both on same server just different folders .. so html file is in a folder like
http://server/CustomLayouts/dt.html
and all javascript code has to be in a different folder
http://server/Static/Custom/js/apps/dt/*

ive tried specifying a different path in Ext loader config but that doesnt seems to be applied its still looking for a view.user.List.js relative to CustomLayouts/ folder

dongryphon
28 Jul 2012, 1:15 AM
There are really two players in your example: the Loader and MVC. I would first try a simple, non-MVC use of "requires" with your Loader.setPath and see how that works. I suspect the problem has to do with how MVC formulates things rather than the Loader.

Also, if you files are on the same server, but just in different folders, I would recommend a relative path to address them. But a full path should work, of course, assuming you get the server name right... and the port... and the protocol. ;)

adeelmahmood
28 Jul 2012, 11:23 AM
so are you saying i cant use the mvc pattern at all ?

also i tried relative path .. something like ../../../Folder

didnt seemed to make any difference .. so with mvc loader config path is ignored .. is there a way to specify the path for mvc stuff

dongryphon
28 Jul 2012, 12:11 PM
so are you saying i cant use the mvc pattern at all ?

Of course not. :) I am suggesting an experiment to separate the two factors at play in your example. At present, it is not clear if the issue you are running in to is with the Loader or MVC. Once we determine which, we can pursue solutions to the right problem.


also i tried relative path .. something like ../../../Folder

didnt seemed to make any difference .. so with mvc loader config path is ignored .. is there a way to specify the path for mvc stuff

The MVC package does not ignore the Loader paths, but it makes certain assumptions about namespaces. These are then fed to the Loader.

So, in this case, let's first see if the Loader can load something properly in your situation outside of MVC using the setPaths that you have and only basic "requires". Either Ext.require or a simple class-level "requires" statement.

If that works, the issue must be with MVC and how it interacts with the Loader.

Make sense?

adeelmahmood
30 Jul 2012, 9:10 AM
yup makes sense

I tried using the regular Ext.require without the mvc setup and it does seems to pick up correct path from the loader so the problem seems to be with mvc not the loader ..

adeelmahmood
30 Jul 2012, 9:33 AM
by specifying the custom path in Ext.application in appFolder property or the paths property both seem to work ..

Ext.application{
name: 'DT',
appFolder: 'custom path'

OR

paths: {
DT: 'custom path'
}
}