Flowdock
method

form_remote_tag

Importance_2
form_remote_tag(options = {}) public

Returns a form tag that will submit using XMLHttpRequest in the background instead of the regular reloading POST arrangement. Even though it’s using JavaScript to serialize the form elements, the form submission will work just like a regular submission as viewed by the receiving side (all elements available in @params). The options for specifying the target with :url and defining callbacks is the same as link_to_remote.

A "fall-through" target for browsers that doesn’t do JavaScript can be specified with the :action/:method options on :html.

Example:

  form_remote_tag :html => { :action =>
    url_for(:controller => "some", :action => "place") }

The <a href="/rails/Hash">Hash</a> passed to the :html key is equivalent to the options (2nd) argument in the FormTagHelper.form_tag method.

By default the fall-through action is the same as the one specified in the :url (and the default method is :post).

Show source
Register or log in to add new notes.
November 12, 2008
1 thank

Ajax form

<% form_remote_tag :url => { :action => “analyze”}, :update => “result” do %>

  <%= select_tag 'company_id', options_for_select([]) %><br/>
  <%= text_area_tag :text, nil, { :cols => 100, :rows => 10 }%><br/>
  <%= submit_tag "Analyze", :disable_with => "Please wait..." %>
<% end %>
<div id="result"></div>