We used to have a form in our Rails 2.3.5 application as below which worked perfectly
<% form_for @quote do |f| -%>
<%= f.text_field :length %>
<%= f.text_field :tax, :readonly => true %>
<%= submit_to_remote 'commit', 'Calculate', :url => { :action => 'create' } %>
<%= submit_tag 'Submit' %>
<% end %>
Basically the ‘Calculate’ button would submit the form as a XMLHttpRequest request while the ‘Submit’ button would do a simple POST. Is it possible to do this in a Rails 3 application?
Add
:remote => trueto yourform_foroptions to generate a form withdata-remote="true", which Rail’s Unobtrusive JavaScript will submit via AJAX.The form will be submitted via AJAX if JavaScript is available, and fallback to a regular form post-back otherwise.