Reputation: 568
I am building a sencha touch application, in which I have requirement to load controller dynamically mean (programmatically), not through defining it in app.js.
Upvotes: 2
Views: 1070
Reputation: 181
Try this code:
Ext.require(controller, function() {//controller - "App.controller.Name"
var c = Ext.create(controller, {application: this}), controllers;
c.init();
c.launch();
/*
The "getController" returns "undefined" for a dynamically loaded controller, so the "controllerInstances" should be updated.
*/
controllers = this.getControllerInstances();
controllers[controller] = c;
this.setControllerInstances(controllers);
}, this.getApplication());
Upvotes: 5