aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
authorStefan Penner <stefan.penner@gmail.com>2010-01-31 16:30:21 -0600
committerJoshua Peek <josh@joshpeek.com>2010-01-31 16:37:33 -0600
commitc493370f332715dee0ef795a66e896d7f0471cbe (patch)
tree4af0d4e99d514e1b6675eae7f1c91beab4500af2 /actionpack/lib/action_view/helpers/form_helper.rb
parente1618b9ac397d1963e788f441fc4965cd3f9d4cf (diff)
downloadrails-c493370f332715dee0ef795a66e896d7f0471cbe.tar.gz
rails-c493370f332715dee0ef795a66e896d7f0471cbe.tar.bz2
rails-c493370f332715dee0ef795a66e896d7f0471cbe.zip
UJS documentation.
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 54610fdc71..a72357cf3d 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -225,6 +225,33 @@ module ActionView
# ...
# <% end %>
#
+ # === Unobtrusive JavaScript
+ #
+ # Specifying:
+ #
+ # :remote => true
+ #
+ # in the options hash creates a form that will allow the unobtrusive JavaScript drivers to modify its
+ # behaviour. The expected default behaviour is an XMLHttpRequest in the background instead of the regular
+ # POST arrangement, but ultimately the behaviour is the choice of the JavaScript driver implementor.
+ # 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 <tt>params</tt>).
+ #
+ # Example:
+ #
+ # <% form_for(:post, @post, :remote => true, :html => { :id => 'create-post', :method => :put }) do |f| %>
+ # ...
+ # <% end %>
+ #
+ # The HTML generated for this would be:
+ #
+ # <form action='http://www.example.com' id='create-post' method='post' data-remote='true'>
+ # <div style='margin:0;padding:0;display:inline'>
+ # <input name='_method' type='hidden' value='put' />
+ # </div>
+ # ...
+ # </form>
+ #
# === Customized form builders
#
# You can also build forms using a customized FormBuilder class. Subclass