Re: Re: form submit events

"Ian Petersen" <[email protected]> Thu, 16 Mar 2006 10:59:09 -0500
Newsgroups gmane.comp.web.dom.wdf
Message-ID <[email protected]>
I'm pretty sure one event listener can't block another listener on the
same node and event.  You can only stop the event from bubbling
further up the document tree.

In other words, say you have this:

<div id="div">
  <input type="button" id="button" />
</div>
<script type="text/javascript">
function divClick(event) {
}

function buttonClick1(event) {
}

function buttonClick2(event) {
}

document.getElementById('div').addEventListener('click', divClick, false);
document.getElementById('button').addEventListener('click',
buttonClick1, false);
document.getElementById('button').addEventListener('click',
buttonClick2, false);
</script>

Then buttonClick1 and buttonClick2 can block divClick from being
called by doing event.stopPropagation() (or the IE equivalent), but
buttonClick1 and buttonClick2 are both guaranteed to run in some
arbitrary order.

Ian

On 3/16/06, Gerry Hornik <[email protected]> wrote:
> Can't this simply be accomplished by having the event handler return
> false? It works for an onclick handler.
>
> Gerry Hornik
>
>
> On Mar 16, 2006, at 4:43 AM, [email protected] wrote:
>
> Hello!
>
> I'm adding two event listeners to the submit event of a form.
> The first event handler performs a validation, the second handles the
> form submission (I need do do some extra stuff before submitting the
> form).
>
> My problem:
> I can't find out how the first event handler should do to stop event
> propagation to the second one (in case of failed validation). I've tried
> to handle capture/bubble phase and so on, but still can't get it right.
>
> Does anyone have a working example of multiple submit event handlers?
> Any special gotchas when doing stopping form submit events?
>
> /AndersN
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> Unsubscribe
> [email protected]
>
> List info
> http://www.quirksmode.org/dom/list.html
> Yahoo! Groups Links
>
>
>
>
>
>
>


--
Tired of pop-ups, security holes, and spyware?
Try Firefox: http://www.getfirefox.com


Unsubscribe
[email protected]

List info
http://www.quirksmode.org/dom/list.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wdf-dom/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/