Ok smart JavaScript people, my assumption is if there were a way to do
cross browser event capturing it would have been in Prototype already,
correct?

So far the only place I have really needed to get the event in the
capture phase was when I wanted to get the next click anywhere on the
page. It's for a feature kind of like the "more" dropdown at the top
of google.com where once activated the next click anywhere on the page
will close the dropdown.

The logical thing to do would be document.observe('click', function()
{}, true). Of course we all know that IE doesn't support capture and
Prototype doesn't even look at that parameter anymore. So my pre 1.6
"simulation" was to add a method (pause) to Event that saves off all
of the current observers and then stop and clear them all. The inverse
Event method (resume) restores all of the observers that I stored off.
This gave me...

Object.extend(Selection.prototype, {
initialize: function() {
  ...
  Event.pauseCurrentObservers();
  Event.observe(document, 'mousedown', this.close.bind(this));
  ...
},

close: function() {
  Event.unloadCache();
  Event.resumePausedObservers();
  ...
},

...
});

I know it's not true a capturing phase, but it works for my particular
use case. All was well until I wanted to upgrade to 1.6 which
completely revamps the whole Event model, which btw was for the
better.

So, I guess my question is, has anyone solved this problem before? Am
I missing something obvious that would make this easier?

Also, for the Prototype devs, from a quick look through the new Event
stuff there doesn't appear to be a way to get back to the element from
the Event.cache entry, correct?

Darrin
--~--~---------~--~----~------------~-------~--~----~
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