Removing a listener from the panel

Is it possible to remove a listener from Ext.Panel after a call? I have a crane listener that I want to remove after a call for the first time. I tried many ways to remove the listener, but it still rings:

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();
}

Am I really confused?!? :( Any suggestions?

+3
source share
1 answer

Yes, you can set a 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 out the docs for addListener at http://dev.sencha.com/deploy/touch/docs/?class=Ext.Component

+4
source

Source: https://habr.com/ru/post/1796309/


All Articles