Tariq
Tariq

Reputation: 58

Removing Listener from Panel

is it possible to remove a Listener from an Ext.Panel after 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?

Upvotes: 3

Views: 4809

Answers (1)

ChrisR
ChrisR

Reputation: 14467

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

Upvotes: 4

Related Questions