Unable to access global variable entire one controller in sencha

让人想犯罪 __ 提交于 2019-12-06 09:14:52

The problem is about scope and you can solve it by:

In your controller init method

init : function() {
   me = this;
}

Now access the methods using

   me.setSuccessMessage(1)

   me.getSuccessMessage();

I think you ran onto the scope visibility issue... I'm not sure where an exception is emitted, from onSearchKeyUp() or from Confirm(). But guess inside it this points not to the controller instance. To help you more you need share more info (sources)

The success function inside onSearchKeyUp has a different scope when it is called. So, inside it, this is not your controller where the successMessage (and of course, its getter and setter) is defined.

A solution is to "bind" the success function to the controller scope using:

success: Ext.bind(function (response) {
       this.setSuccessMessage(1);
}, this);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!