Possible Duplicate:
Removing an anonymous event listener
I have the following cross browser function to add an event listener:
_SU3.addEventListener = function(elem, eventName, fn) {
if(elem.addEventListener ) {
elem.addEventListener(eventName, fn, false);
} else if (elem.attachEvent) {
elem.attachEvent('on'+eventName, fn);
}
};
I'm adding the listener like this:
_SU3.addEventListener(_show, "click", function(event) {
_SU3.getChildren(_show, uri, element);
});
Which is all fine. However I want to remove the listener after it has been called once. I.e. something like:
_SU3.getChildren = function(_show, url, element) {
... blah...
_SU3.removeEventListener(_show, 'click', ANON_FUNCTION);
};
But of course the listener function is anonymous so there's no function name to reference.
How can I remove the listener?