The question is in the topic. I'm trying to do it in Sencha Touch 2.0 according to solution in ExtJS 4 (http://www.sencha.com/forum/showthre...oller&p=787028), but unfortunately it isn't working.
I added in my application function for loading controllers.
Code:
Ext.app.Application.prototype.addController = function(classPath, config) {
var self = this,
config = config || {};
Ext.Loader.setConfig({ enabled: true });
Ext.require(classPath);
Ext.require(classPath, function() {
var controller = Ext.create(classPath, Ext.apply({
application : self
}, config.options || {}));
//self.controllers.add(classPath, controller);
self.controllers.push(classPath);
controller.init();
if (config.callback) { config.callback.call((config.scope || this), config); }
});
};
But the problem is that self.controllers.add(classPath, controller) can't be done, because self.controllers in Sencha Touch is an array (not class object) and it hasn't method add(). How to load instance of controller in app?
And of course, after method init() when I try to get my added before controller I get nothing. My code:
Code:
var app = this.getApplication();
app.addController('ContactsController',
{
callback : function() {
console.log(self.application);
}
});
var myController = this.getApplication().getController('ContactsController');
myController is undefined (but I see ContactsController in array of controllers ('cause I pushed it in array self.controllers) but it's not loaded.