Hi there,
I'm quite a new French user of sencha touch 2 and really appreciate this tool.
I need to develop an application which works with widgets (lets all it MyApp). Let me explain :
My application has a list of services. Each service is actually a little application (like a widget).
Services are on the web server, but I wan't my app to be stand alone.
I can't have written my services classes (models, views, controllers) in my application folders because services have to be developped and managed separately (that's mean I would like to be able to add or remove services whenever I wan't)
I imagined a solution like that :
Code:
MyApp/
view/
Widget.js
controller/
Widget.js
When I initialize my Widget js, I launch an Ajax request (CORS), like that :
Code:
Ext.Ajax.request({
url: 'http://myserver/myscript.php',
useDefaultXhrHeader: false,
success: function(response) {
//myscript.php only contains javascript so I simply eval it
eval(response.responseText);
// I create a page with A class 'ScriptPage' written in myscript.php and evaluated in ajax success
var page=Ext.create('Test.view.ScriptPage');
//I had it on my viewport,
Ext.getCmp('viewPort').add(page);
}
});
The aim is to load new classes from ajax request and then work with theses new classes.
Now let's have a look on what is myscript.php on server side.
myscript.php only contains javascript. I use smarty to generate the all code with fetching files like this :
Code:
{* ------ MODELS -------- *}
{fetch file='templates/mobile/model/Widget.js'}
{* ------ CONTROLLERS -------- *}
{fetch file='templates/mobile/controller/Widget.js'}
{* ------ VIEW -------- *}
{fetch file='templates/mobile/view/ScriptPage.js'}
As a result of this, this is only javascript with classes code displayed.
I wan't to keep my code well organized so I used the same folder organisation.
Unfortunately, when I try to create a Test.view.ScriptPage instance, there is an error :
Uncaught Error: [Ext.Loader] Failed loading 'app/view/ScriptPage.js',
That is for use, this file doesn't exists on the application side, it's on the server side, but the class Test.view.ScriptPage should exists cause I got it with my ajax request and evaluated it....
Well that was just to illustrate what I'm trying to do.
What experts suggest ? My need is to be able to load classes with ajax request and use them.
Thanks in advance.
Please don't hesitate to ask for more precision if needed.
Regards