Eric Harrison wrote:
> I didn't realize that your question was centered around the fact that
> your events were still being observed. I just thought you wanted to
> know what the deal was with the observers array.
>
> As stated above, you cannot remove events that you attached with an
> anonymous function.

It was't stated above, and you can:

  element.onclick = null;

will remove all the onclick handlers from element.

> References:
>
> http://joseph.randomnetworks.com/archives/2006/08/01/javascript-events-with-prototype/

Which states:

  "You can not use Event.stopObserving if you used an anonymous
   function in Event.observe."

Which isn't quite right - you can use it but it won't work.  What it
should say is that Event.stopObserving can't remove anonymous
functions.

And if you know that, and that you *can* remove anonymous functions
from an element provided you don't mind removing all of them, then you
might be able to design around the issue.

It is also good to know that Event.stopObserving() is only useful if
you have attached multiple handlers for the same event, or only want to
remove a particular named function.

> http://www.andrewdupont.net/2006/05/07/undecidability-of-equivalence-or-the-pitfalls-of-advanced-event-listening/
>

The myth is perpetuated:

  "if we try to assign the [anonymous] event listener in this manner,
   we won't be able to remove it later"

Which is plain wrong, see above.


-- 
Rob


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to