Reputation: 710
I've added an event like so:
this.getLetters().element.on({
tap: me.lettersTap,
delegate: 'span.letter-hidden'
});
based on user interaction, I'm adding another class to those elements, so it will be:
<span class="letter-hidden new_class">
I want to remove the event handler based on the "new_class",but got no clue how. I tried like:
questionController.getLetters().element.un({
tap: questionController.lettersTap,
delegate: 'span.new_class',
scope: questionController
});
but it's not working, I am able to remove it if I replace the "new_class" with letter-hidden in the above code, so I suppose works to be removed if the same class is used, which is not mentioned in documentation. Am I doing something wrong, an alternative would be nice to have it...Thanks.
Upvotes: 2
Views: 2408
Reputation: 23975
You used a delegate so it would be important to use exactly the same when you are trying to remove it. Otherwise ExtJS must expect it is a different element, which is a correct behavior.
This is how the registered listeners get checked:
(registered.fn === remove.fn &&
registered.scope === remove.scope &&
registered.delegate === remove.delegate &&
registered.order === remove.order)
So no, there is no alternative way. You have to unregister with the same properties as you registered it.
Note: Sencha don't use your properties to query within the DOM it just lookup in the oberservalbe listeners collection for a listener that was registered like the one you handed to unregister.
Upvotes: 2