是否可以在調用之後從一個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();
}
我真的很困惑?!? :(任何建議?
爲的addListener的文檔你有沒有注意到你正在設置監聽器在this.view上,但是在this.view.el上取消設置它是故意的嗎? – ChrisR 2011-03-04 19:26:07
哦,這是錯誤的,我必須用this.view.getEl()。on和this.panel.getEl()重新測試它。removeListener – Tariq 2011-03-07 13:11:16