Hi,

> And later, I'm adding another event handler to it with $
> ('myinput').observe('submit', foofunc);

I don't think input elements have a submit event.  Form elements do.
So that would be step one. :-)

Is it really necessary to use old DOM0-style event handlers (the
attribute on the tag) and modern event attachment in the same app?
Wouldn't it be cleaner to use observe() for all of your event
handlers, rather than mix-and-match?  Or, I suppose, use DOM0 for
everything, but there's a reason things have moved on in the last
decade and a half or so... ;-)

> <input... id="myinput" onClick='some javascript statements + function
> calls here...'>

Out of curiousity, what kind of input element is it?  (That elipsis
could cover a lot of ground.)  button?  submit?  text?  checkbox?
>From your overall question I'm thinking it's probably a submit button,
but...

> It so happens that the handler i've added through observe is always
> getting called first (I'm not 100% of this BTW. Is this true that
> handlers added later will always execute first?)

No, I'm afraid not.  The order in which handlers for the *same* event
on the *same* element are called is undefined and implementation-
specific (most browsers do it one way, IE does it a different way).
Separately, the order of DOM0 handlers relative to the chain of modern
handlers is also not defined.

The order of some events (as opposed to handlers) is defined or at
least consistent, though:  For instance, if you have a submit button
in a form with a click handler where the form has a submit handler,
the click event on the button fires before the submit event on the
form in every browser I'm aware of (it's probably even defined
somewhere, but I don't have a reference for it).

Probably the best way forward is to step back and tell us what the
ultimate goal and any related constraints are; I'm sure once we know,
one of us will be able to make some helpful suggestions.

FWIW,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Mar 18, 5:13 am, Jay <jebum....@gmail.com> wrote:
> I'm using prototype 1.6+ and I can't figure this out.
>
> There is event handler registered through the onclick HTML property.
>
> <input... id="myinput" onClick='some javascript statements + function
> calls here...'>
>
> And later, I'm adding another event handler to it with $
> ('myinput').observe('submit', foofunc);
> It so happens that the handler i've added through observe is always
> getting called first (I'm not 100% of this BTW. Is this true that
> handlers added later will always execute first?) So far so good.
>
> But based on logic I have in foofunc, I need to stop the propagation
> from exucuting javascript code registered through onClick property but
> I can't do this.
> Calling event.stop() won't help either.
> I'd love any suggestions on this. Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to