Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sencha touch 从面板中删除侦听器_Sencha Touch_Extjs - Fatal编程技术网

Sencha touch 从面板中删除侦听器

Sencha touch 从面板中删除侦听器,sencha-touch,extjs,Sencha Touch,Extjs,呼叫后是否可以从外部面板删除侦听器? 我有一个tap侦听器,我想在第一次调用后删除它。我尝试了多种方法删除侦听器,但它仍在调用: registerListeners: function() { // this = Ext.Controller // this.view = Ext.Panel this.view.on('tap', this.onTap, this, {element: 'body'}); }, unregisterListeners: function(

呼叫后是否可以从外部面板删除侦听器? 我有一个tap侦听器,我想在第一次调用后删除它。我尝试了多种方法删除侦听器,但它仍在调用:

registerListeners: function()
{
   // this = Ext.Controller 
   // this.view = Ext.Panel
    this.view.on('tap', this.onTap, this, {element: 'body'});
},

unregisterListeners: function(evt, el, o)
{   
    console.log("Removing Event...");
    this.view.el.un('tap', this.onTap, this);   // Don't work, on the next tap its still calling
},

onTap: function(evt, el, o)
{
    Ext.ControllerManager.get('mycontroller').unregisterListeners();
}

我真的很困惑(有什么建议吗?

是的,您可以在on/addListener调用中设置单个选项

myButton.on('click', function(){ 
    /* do stuff */ 
}, this, { single : true });

// In your case:
this.view.on('tap', this.onTap, this, {element: 'body', single: true});

查看addListener on的文档

哦,你是对的,但它仍然在呼叫?!这真的很奇怪…可能是一个bug?你测试过它吗?我已经使用了single:true选项好几次了是的,但我不知道你的应用程序还涉及到什么,它在什么地方是公共的,我们可以检查吗?我在一个单独的项目中测试过它,它可以工作。也许它是一个与sencha.Thx冲突的其他组件或库:)您是否注意到您在this.view上设置了侦听器,但在this.view.el上取消了它的设置?这是故意的吗?哦,这是错误的,我必须用这个.view.getEl().on和这个.panel.getEl().removeListener再次测试它