Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 828
Tariq Avatar asked Jul 23 '26 17:07

Tariq


1 Answers

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

like image 58
ChrisR Avatar answered Jul 28 '26 16:07

ChrisR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!