Skip to content
This repository
Browse code

Added a fall-through action for form_remote_tag that'll be used in ca…

…se Javascript is unavailable #1459 [Scott Barron]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1464 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit e59bfc85196cc4921f87b4b145048b7fa1fbbabb 1 parent 1e0d9a6
David Heinemeier Hansson authored June 21, 2005
4  actionpack/CHANGELOG
... ...
@@ -1,5 +1,9 @@
1 1
 *SVN*
2 2
 
  3
+* Added a fall-through action for form_remote_tag that'll be used in case Javascript is unavailable #1459 [Scott Barron]. Example:
  4
+
  5
+    form_remote_tag :html => { :action => url_for(:controller => "some", :action => "place") }
  6
+
3 7
 * Added :xhr => true/false option to verify so you can ensure that a request is coming from an Ajax call or not #1464 [Thomas Fuchs]
4 8
 
5 9
 * Added tag_options as a third parameter to AssetHelper#auto_discovery_link_tag to control options like the title of the link #1430 [kevin.clark@gmail.com]
8  actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -97,11 +97,19 @@ def periodically_call_remote(options = {})
97 97
       # reloading POST arrangement. Even though it's using Javascript to serialize the form elements, the form submission 
98 98
       # will work just like a regular submission as viewed by the receiving side (all elements available in @params).
99 99
       # The options for specifying the target with :url and defining callbacks is the same as link_to_remote.
  100
+      #
  101
+      # A "fall-through" target for browsers that doesn't do Javascript can be specified with the :action/:method options on :html
  102
+      #
  103
+      #   form_remote_tag :html => { :action => url_for(:controller => "some", :action => "place") }
  104
+      #
  105
+      # By default the fall-through action is the same as the one specified in the :url (and the default method is :post).
100 106
       def form_remote_tag(options = {})
101 107
         options[:form] = true
102 108
 
103 109
         options[:html] ||= {}
104 110
         options[:html][:onsubmit] = "#{remote_function(options)}; return false;"
  111
+        options[:html][:action] = options[:html][:action] || url_for(options[:url])
  112
+        options[:html][:method] = options[:html][:method] || "post"
105 113
 
106 114
         tag("form", options[:html], true)
107 115
       end

0 notes on commit e59bfc8

Please sign in to comment.
Something went wrong with that request. Please try again.