Hi,

> Very strange but I'll take your word on it.
>
> Although I can't say I understand why the object wouldn't throw its
> submit event after executing the submit method.

Because by design, submitting a form programatically doesn't fire the
onsubmit event.  I think this is on the theory that if you're doing it
with code, you've already done whatever checks you want to do.  This
is not well documented as far as I can tell, but is the case on every
browser I've ever tried it on.
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Mar 19, 7:24 pm, Matt Foster <mattfoste...@gmail.com> wrote:
> Very strange but I'll take your word on it.
>
> Although I can't say I understand why the object wouldn't throw its
> submit event after executing the submit method.
>
> If another method, one that isn't handling the event called the submit
> method, would it be caught by the submit listener?
>
> --
>
> http://positionabsolute.net
>
> On Mar 19, 12:03 pm, Marko Zabcic <gm.ma...@gmail.com> wrote:
>
> > You can also do this:
>
> > $('foo').observe('submit',function(evt){
> >                 evt.stop(); //shorter way
> >                 console.log('bar');
> >                 this.submit();
> >         });
>
> > On Mar 18, 11:45 pm, "Alex Mcauley" <webmas...@thecarmarketplace.com>
> > wrote:
>
> > > There is no exception or error thrown in firebug !!
>
> > > I went round it with an inline call instead !
>
> > > Thanks for help guys
>
> > > Alex
>
> > > ----- Original Message -----
> > > From: "Matt Foster" <mattfoste...@gmail.com>
> > > To: "Prototype & script.aculo.us" 
> > > <prototype-scriptaculous@googlegroups.com>
> > > Sent: Wednesday, March 18, 2009 8:26 PM
> > > Subject: [Proto-Scripty] Re: Stopping events ..
>
> > > Event.stop(e) does indeed prevent event propagation.  I would assume
> > > that your code is hitting an exception before Event.stop is being
> > > executed.
>
> > > > Try calling Event.stop() at the very beginning of the script, before
> > > > anything else, then if there are no errors, call event.form.submit()
> > > > to carry on with the original submit event.
>
> > > @Walter: If you have a submit handler that executes the object's
> > > submit event wouldn't this lead to an infinite loop?
> > > Wouldn't the idea be, catch the submit event, validate the fields, if
> > > all is valid, allow the event to proceed, if its not then stop the
> > > event.
>
> > > function handleLoad(){
>
> > >    $("myForm").observe("submit", function(e){
>
> > >    var invalidArr = $("myForm").select("input.req, textarea.req,
> > > select.req").findAll(function(element){ return element.value != "" });
> > >    if(invalidArr.length > 0){
> > >         e.stop(); //prototype 1.6 code to event stop.
> > >         handleInvalids(invalidArr )
> > >    }
> > > });
>
> > > }
>
> > > Event.observe(window, "load", handleLoad);
>
> > > --
>
> > >http://positionabsolute.net
>
> > > On Mar 18, 11:59 am, Walter Lee Davis <wa...@wdstudio.com> wrote:
> > > > Try calling Event.stop() at the very beginning of the script, before
> > > > anything else, then if there are no errors, call event.form.submit()
> > > > to carry on with the original submit event.
>
> > > > Walter
>
> > > > On Mar 18, 2009, at 11:45 AM, Alex Mcauley wrote:
>
> > > > > It still does not work with "Event.stop(event);" for some reason ....
>
> > > > > i even tried changing the code to .....
>
> > > > > var error='';
> > > > > $$('.req').each(function(e) {
>
> > > > > if($(e).value=='') {
> > > > > error+='Required';
>
> > > > > }
>
> > > > > });
> > > > > if(error.length>=1) {
> > > > > alert(error)
> > > > > Event.stop(event); // does not work
>
> > > > > }
>
> > > > > ----- Original Message -----
> > > > > From: "Alex Mcauley" <webmas...@thecarmarketplace.com>
> > > > > To: <prototype-scriptaculous@googlegroups.com>
> > > > > Sent: Wednesday, March 18, 2009 3:42 PM
> > > > > Subject: [Proto-Scripty] Re: Stopping events ..
>
> > > > >> Doh !!!!!! i knew it was something simple !!
>
> > > > >> Thanks
> > > > >> Alex
> > > > >> ----- Original Message -----
> > > > >> From: "Walter Lee Davis" <wa...@wdstudio.com>
> > > > >> To: <prototype-scriptaculous@googlegroups.com>
> > > > >> Sent: Wednesday, March 18, 2009 3:11 PM
> > > > >> Subject: [Proto-Scripty] Re: Stopping events ..
>
> > > > >>> Has to be capital E event:
>
> > > > >>> Event.stop(event)
>
> > > > >>> Walter
>
> > > > >>> On Mar 18, 2009, at 10:40 AM, Jeztah wrote:
>
> > > > >>>> event.stop(event); // doesnt stop the request from firing
>
>
--~--~---------~--~----~------------~-------~--~----~
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