Removing Listener from Panel
is it possible to remove a Listener from an Ext.Panel after开发者_JAVA技巧 the call? I have a tap-Listener, which I want to remove after calling the first time. I tried many ways to remove the Listener but it's still calling:
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();
}
I'm really confused?!? :( Any suggestions?
Yes, you can set the single option in the on/addListener call.
myButton.on('click', function(){
/* do stuff */
}, this, { single : true });
// In your case:
this.view.on('tap', this.onTap, this, {element: 'body', single: true});
Check the docs for addListener on http://dev.sencha.com/deploy/touch/docs/?class=Ext.Component
精彩评论