是否可以在调用后从 Ext.Panel 中删除一个监听器? 我有一个 tap-Listener,我想在第一次调用后将其删除。我尝试了很多方法来删除监听器,但它仍在调用:
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});
在 http://dev.sencha.com/deploy/touch/docs/?class=Ext.Component 上查看 addListener 的文档
关于sencha-touch - 从面板中删除监听器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5195115/