问题
I need to use a customize path for the Ext.Loader in my MVC project. I've already looked through the API and found nothing useable. If I set the loader directly it gets simply overriden, as it seems by the MVC app settings. So how can I customize the loader path for a MVC app?
In addition: It would be awesome if the loader could be tweaked to sumarize multiple requirements that occours by the same source into one request. Would that be possible?
Thanks in advance for any suggestions
Edit
The loader by default calling something like app/controller/MyController.js
or app/store/MyStore.js
My goal is to modify this path like load/data/app/controller/MyController
or better load/data?ident=app.controller.MyController
or best request via JSON
Edit 2
Thanks for all reply! I looked again into the sourcecode of the Ext.app.Application but I could not find where the loader get initialized. Yes, I found the appFolder property but not where it is used. And my Problem with the appFolder approach is, that I can't use routes because of the applied GET param. So guess the best is to modify the Ext.Loader, isn't it? Or is the loader capable of loading entire namespaces?
回答1:
You can set the 'appFolder' config property in your application if you need to change the root relative to the website.
For example, if you have www.mysite.com but you want to store you .js files in www.mysite.com/scripts/ext/ you could do something like this:
Ext.application({
name: 'MySite',
appFolder: '/scripts/ext'
});
Not sure if that's quite what's being asked here, but might give you a start point.
回答2:
I guess what you are trying to archive is not possible without many modifications. You have to change the loader for that so that it fit your request needs. I think you may go better to define some routes in your backend and use the approach @dougajmcdonald wrote. I think you will endup in nearly the same.
But you should note that it is much faster when you let Webserver fetch the files then doing it per code.
来源:https://stackoverflow.com/questions/13699045/customize-the-loader-for-a-mvc-app