I am working in extjs4.I am getting stuck at a point where I want to load controller dynamically in extjs4.I am using controllers this.getController() method to load controller dynamically. *When I am placing this code in init() function of particular controller then it works and controller get loaded dynamically.*Here is my controller code...
Ext.define('B.UserController',{
----
init:function()
{
var controller = this.getController('kp.PollController');
controller.init(); // launch init() method
this.control(
{
'KpLogin button[action=loginAction]':
{
click:this.authenticateUser
},
});
},
-----
But when I am placing my code in particular function(buttons event) then it gives me error. Here is my code...
Ext.define('B.UserController',{
-------
init:function()
{
this.control(
{
'KpLogin button[action=loginAction]':
{
click:this.authenticateUser
},
});
},
authenticateUser:function(button)
{
var controller = this.getController('kp.PollController');
controller.init(); // launch init() method
}
-----
After placing this code in then I got error in firebug...
Uncaught TypeError: Cannot read property 'readyState' of undefined Connection.js:818
Ext.define.onStateChange Connection.js:818
(anonymous function)
Here is my app.js code....
Ext.application({
name:'B',
autoCreateViewport:true,
controllers:['sn.UserController','qb.QbquestionController','kp.DnycontentController',/*'kp.PollController','kp.PolloptionController',*/'kp.KpquotationController','qb.QbqnsController','kp.CuriosityquestionController','kp.WordController','kp.DnycontentcategoriesController'],
launch:function()
{
console.log('Application launch');
},//End of launch function
});
I dont know whats going wrong.Please give me some suggestions....
You can put below code in the authenticateUser function
authenticateUser:function(button) {
var app = this.getApplication(),
controller = Ext.create('kp.PollController', {
application: app
});
app.getControllerInstances()['kp.PollController'] = controller;
controller.init();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With