Re: Rail3: UJS submit after client-side validation

AppleII717
2010-08-15T14:58:47Z

On Aug 14, 10:24 am, AppleII717 <sa...-ee4meeAH724@public.gmane.org>
wrote:
...
> Debugging all seemed to work (names, classes, etc)
>
> Behaviors.add("click", "validate", function(element) {
>   var formElements = $$(".required", ".required-one");
>   var valid = true;
>   var thisform = element.form
>   ... validations stuff
>
> but when I got to the end
>   if(valid){thisform.submit()}
>
> would fail saying the input element does not have a function submit.
> thisform is reported as and htmlformelement.
...

This must have been one of those posts where nobody knew what I was
talking about. That just spawns another learning exercise.

My problem was I didn''t understand Javascript as much as I should to
even ask the question. At least I didn''t know about anonymous
functions.

I solved my problem when I figured out how those functions work, and
more importantly, what arguments are passed to them.

Just in case anyone wants to know about Unobtrusive Javascript on the
client side, I posted a gist <http://gist.github.com/525561> that
outlines my learning experience and how I got it to work.

The sort version is, all that I needed was:
   if(!valid){event.stop()}

To stop the onsubmit event from propagating. I didn''t know I had
"event" available in my Behaviors.add function.

Steve

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at