Reputation: 11
I want suspend the click event for a node temporarily .
I want to get the click event handler for a node and detach it and then reattach it when I want it again.
I am using YUI 3.
Can some one tell me how could I query the click event handlers for a node and detach them?
Upvotes: 1
Views: 1425
Reputation: 2581
See Y.Event.getListeners - http://yuilibrary.com/yui/docs/api/classes/Event.html#method_getListeners
For all the various ways you can detach events, see http://yuilibrary.com/yui/docs/event/#detach-methods
Upvotes: 1
Reputation: 39678
on() returns a subscription object that can be used to unbind that subscription
var subscription = myNode.on("click", handleClick);
//unbind the subscription
subscription.detach();
Or you can use the Node's detach() method if you didnt get the subscription object
myNode.detach("click", handleClick); //detaches only handleClick
or if you want to dettach all click handlers :
node.detach('click');
Upvotes: 0