I've implemented "submit" and "change" events bubbling in this Prototype 1.7
plugin:
http://gist.github.com/382731

Stick it in your projects, give it a whirl! *Warning:* it doesn't work with
the `observe` method, you have to use `on`. Example:

document.on("submit", function(e) {
  e.findElement().findFirstElement().setValue("You're a kitty!")
  e.preventDefault()
})

It uses Kangax's feature detection to see whether the events in question are
supported on the "DIV" element (that is, if they bubble or not).

Then I use the "focusin" event to discover FORM, INPUT, SELECT and TEXTAREA,
then I stick handlers on them to observe real events and fire the
"emulated:submit" or "emulated:change" custom events which bubble.

Finally, I monkeypatch Event.Handler#initialize to magically change attempts
to observe the bubbling *native* event to observing the *emulated* event.

*Known bug:* if the user observes the real "submit" event directly on a form
element and calls `stopPropagation()` in this handler, the "emulated:submit"
event will still fire and will still bubble up. This is because I don't know
how to detect whether or not stopPropagation was called, and even if I
could, the order in which "submit" handlers will fire at runtime is probably
not guaranteed, making this problem even more complex.

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en

Reply via email to