问题
I want suspend the click event for a node temporally .
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 ?
回答1:
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
回答2:
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');
来源:https://stackoverflow.com/questions/9391093/yui-find-event-handlers-for-a-node