Are you destroying or disposing the element? There are 2 methods to remove elements from the DOM, destroy() and dispose(). destroy() removes the element from the DOM and really destroy it and its references and, i think, everything related to it (events included). dispose() removes the element from the DOM, and that's it.
So... you might be using dispose. And that's correct as you are removing and adding it again to the DOM, it's more efficient. So just try not to re-add the event. If you still need to re-add, remove the old one first than add the new one. Fábio Miranda Costa Engenheiro de Computação http://meiocodigo.com On Tue, Apr 14, 2009 at 10:56 AM, electronbender <[email protected]>wrote: > > I create a dropdown, and add a change event to it. > > Then i destroy the element. > > After a while i recreate it (same id, same name), and add the same > change event to it. > However, when i actually fire the change event this time around, it is > fired twice! > > So, every time i delete, re-create it, and add the new event, all the > previous events apply, plus the new one. > > So, question 1: > - Why? This is a new element, even though it has the same name, the > event should have died with the old element? > > Question 2: > - How do i prevent it? Is there a way to check if an event has been > applied to an element?
