Hi, It's not the observing the event that's the problem, it's what you're doing in the event handler. My guess is that since the "wait" div appears above the form (and therefore above the submit button), the button never sees a `mouseup`, and hence never sees a `click` and never triggers the form submission at all. Compare http://jsbin.com/aniro4 with http://jsbin.com/aniro4/2 -- in the latter, which introduces a 50ms delay before showing the div, for me, it works, mostly (see below).
But I wouldn't do it there, because almost no matter what value you give the delay, it's going to be fragile, because the delay has to be long enough for the user to release the mouse button, and that's not something you can test for -- every user is different. For instance, if I use a 10ms delay the form almost never gets submitted when _I_ click the button. With the 50ms delay, it almost always does unless I intentionally hold the button down for longer. Also, on most OSes, if you mousedown on a button but then move the mouse off the button before mouseup, it's not a click; you changed your mind. `mousedown` just isn't the right event for this. Instead, I'd do it in the obvious place: The form submit event: http://jsbin.com/aniro4/3 Or you could do it on the `click` event of the button: http://jsbin.com/aniro4/4 (I wouldn't use `mouseup` on the button, in case there are things the user can do that won't trigger the click but *will* trigger `mouseup` -- like pressing down elsewhere, the moving the mouse onto the button and releasing the mouse button. Let's defer to the UA about when the user's actually clicked the button.) HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Oct 21, 5:49 pm, Walter Lee Davis <wa...@wdstudio.com> wrote: > I don't understand why this would be so, but it appears to be true in > my testing here. > > Consider the following form: > > <form action="somewhere/useful" method="post"> > <p><input type="submit" id="send" value="Send" /></p> > <div id="wait" style="display:none"></div> > </form> > > And the following observer in the page head: > > document.observe('dom:loaded', function(){ > $('send').observe('mousedown',function(evt){ > $('wait').show(); > }); > > }); > > The idea being that when the mouse is pressed, (and thus before the > form is submitted, canceling any further page updates) the 'wait' > element is shown, covering the form up with a spinny thing. > > What happens is that the form submission stops dead when I observe the > mousedown, and works fine when I observe the mouseup. This is in > 1.6.latest Prototype, nothing else in the page. > > Can anyone explain why a mousedown observer that does not explicitly > trap the event would still seem to trap the event? > > Thanks, > > Walter -- 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-scriptacul...@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.