2
votes

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.

1

1 Answers

5
votes

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());