PDA

View Full Version : How to remove Listener from Controller?



JSassy
14 Nov 2012, 7:35 AM
Hello,

I'm using ExtJs 4.1.1a and I have no idea how to remove a Listener or to disable it for some time.

I have a controller and I register some events in its init function like this:


this.control({
'mypanel': {
beforeclose: this.onBeforeClose,
clickconstruction: this.onClick
}
});

clickconstruction is fired in another controller with
mypanel.fireEvent('clickconstruction');

Now I am trying to remove the listener or to suspend the events but it does not work:

mypanel.un('clickconstruction', this.onClick);

How do I remove or suspend correctly?

vietits
14 Nov 2012, 5:15 PM
Ext framework does not supply a method to unregister controller. One of the solution is using a flag. For example:


...
init: function(){
this.control({
'mypanel': {
beforeclose: this.onBeforeClose,
clickconstruction: this.onClick
}
});
},
onClick: function(){
if (!this._suspendEvent){
// do handling click event here
}
},
suspendEvent: function(value){
this._suspendEvent = value;
},
...

JSassy
14 Nov 2012, 11:55 PM
Thank you, I'm going to do it that way.