ben.keen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-08 03:06 UTC
Assigning submit handler to form
Hi folks,
A quick question for somebody. I''m adding a simple validation JS to my
form by attaching it like so:
$(''my_form'').observe(''submit'', function(e) {
return
view_ns.validate_form(Event.element(e)); });
The validate_form() function returns true or false. But regardless of
it''s return value, the form is always submitted. ''sup wi
dat''?
Any ideas? Oh, and it''s wrapped in an anonymous function
that''s passed
to a onload bootstrap function. Is THAT where the problem lies?
Thanks! :-)
- Ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
When using observe you have to explicitly stop event:
$(''my_form'').observe(''submit'', function(e) {
if (!view_ns.validate_form(Event.element(e)) {
e.stop(); // Event.stop(e) in 1.5.1
}
})
best,
kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
ben.keen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-08 19:18 UTC
Re: Assigning submit handler to form
Ah, that makes sense. Thanks kangax! On Dec 8, 2:36 am, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> When using observe you have to explicitly stop event: > > $(''my_form'').observe(''submit'', function(e) { > if (!view_ns.validate_form(Event.element(e)) { > e.stop(); // Event.stop(e) in 1.5.1 > } > > }) > > best, > kangax--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---