- Create Account

Remove event

Forums > AddEvent Manager > Remove event
Author
Message

1) gregplaysguitar Group: Members
Posts: 2 Joined: 21 Mar 2007 Location: New Zealand IP: 202.180.--.--
if I add an event using something like

addEvent(el, 'mousedown',  function(){
...
});

Is it then possible to remove this event using removeEvent?
Greg

2) Angus Turnbull Group: Moderators
Posts: 4042 Joined: 7 Dec 2003 Location: New Zealand IP: 202.137.--.--
Hey, good to see you still hacking on the event code ;). Try:

var  hastaLaVista = function(){};
addEvent(el, 'selfdestructsequenceinitiated', hastaLaVista);
removeEvent(el, 'selfdestructsequenceinitiated', hastaLaVista);

You have to track it somehow using a variable. This is as per the DOM specs for add/removeEventListener, just pass a reference to the same function.

Good luck - Angus.

3) gregplaysguitar Group: Members
Posts: 2 Joined: 21 Mar 2007 Location: New Zealand IP: 202.180.--.--
Wow, that was fast!

Thanks- that should work once I refactor a couple of things.

Cheers,
Greg
Greg

Post a Reply:

You are not logged in, and will be posting anonymously as a guest. If you want to post using an account, please login at the top of this page.