Goal: I want to auto-send a form whenever any field changes. The page
will be updated "via Ajax", so standard submission is cancelled.
Idea: Add onchange="document.forms[0].submit();" to every field
Problem: Can not cancel form submission. Browser redirects to
"results"
page, which is of course JavaScript meant to dynamically update the
page.
RHTML snippet:
<%
remote_form_for :estate, :url => { :action => :evaluate_secondhand_flat
} do |form|
%>
<%form.select :province, Constants.provinces_constant, options = {},
:onchange => "javascript: document.forms[0].submit(); /*RETURN FALSE
DOES NOT WORK HERE*/"
%>
HTML snippet:
<form action="/wycena/evaluate_secondhand_flat"
method="post"
onsubmit="new
Ajax.Request(''/wycena/evaluate_secondhand_flat'',
{asynchronous:true, evalScripts:true, parameters:Form.serialize(this)});
return false;">
<select id="estate_province" name="estate[province]"
onchange="document.forms[0].submit();">
Please note, that onsubmit already ends with "return false;" but the
cancellation works only with standard submition via submit button.
Thanks in advance!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---
Calle Dybedahl
2006-Oct-29 19:12 UTC
Re: onchange="document.forms[0].submit()" - how to CANCEL
On 10/28/06, Qertoip <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Goal: I want to auto-send a form whenever any field changes. The page > will be updated "via Ajax", so standard submission is cancelled.onchange="this.form.onsubmit;" -- Calle Dybedahl -*- cdybedahl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Maxim Kulkin
2006-Nov-02 08:27 UTC
Re: onchange="document.forms[0].submit()" - how to CANCEL
On 28 October 2006 14:41, Qertoip wrote:> Goal: I want to auto-send a form whenever any field changes. The page > will be updated "via Ajax", so standard submission is cancelled. > > Idea: Add onchange="document.forms[0].submit();" to every fieldI think, the better idea would be to use Rails'' "observe_form" helper method which eliminates all the pain of adding onchange handlers to each control. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---