我在extjs4.I工作,我陷入了一個點,我想在extjs4中動態地加載控制器。我使用控制器this.getController()方法來動態加載控制器。 * 當我將這段代碼放在特定控制器的init()函數中時,它會工作並且控制器會動態加載。 *這裏是我的控制器代碼...如何在extjs4中的特定事件調用中動態加載控制器?
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
},
});
},
-----
但是,當我把我的特別功能(按鈕事件)代碼,然後它給了我錯誤。 這裏是我的代碼...
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
}
-----
把這個代碼在此之後我的螢火錯誤...
Uncaught TypeError: Cannot read property 'readyState' of undefined Connection.js:818
Ext.define.onStateChange Connection.js:818
(anonymous function)
這裏是我的app.js代碼....
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
});
我不知道怎麼回事wrong.Please給我一些建議....
thanks..johan您reply.Here我更新了我的代碼和我加入app.js代碼普萊舍檢查我遵循你的建議。但仍然沒有問題得到解決。 –
我注意到我在Chrome中出現這個錯誤,但是這個錯誤在Firefox中沒有顯示。 –