开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜