I’m having problems trying to turn off a YUI2 event listener.
I’m doing the following to establish the listener and that works well, but the call to cancelButton returns false and fails. Everytime the dialog opens, the cancel button listener is set, but the cancel function then gets called more and more times since previous listeners weren’t successfully removed.
How can I stop this from happening?
var cancelButton = new YAHOO.util.Element( "buttonid" );
var handleCancelClick = function(e)
{
cancelButton.removeListener(handleCancelClick);
someotherstuff();
};
cancelButton.on('click', handleCancelClick, null, this);
You need to pass the type of event to removeListener.
See http://developer.yahoo.com/yui/event/#removeevent or http://developer.yahoo.com/yui/docs/YAHOO.util.Element.html#method_removeListener