public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Implement submit_to_remote as a wrapper around a more generic button_to_remote

Removed the "return false" from submit_to_remote onclick end as
button input elements have no default behavior to cancel.

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Tarmo Tänav (author)
Mon Oct 06 07:35:21 -0700 2008
lifo (committer)
Mon Oct 06 16:12:20 -0700 2008
commit  51b986619d88f7ba98be7d271188785cbbb541a0
tree    e0fbc752ec252c8a1bef0a5cd96db9a3dd999fa3
parent  8e50f0f96ef53ee8cc7ffa86ce0e71cc357b2b6c
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *Edge*
0
 
0
+* Make PrototypeHelper#submit_to_remote a wrapper around PrototypeHelper#button_to_remote. [Tarmo Tänav]
0
+
0
 * Set HttpOnly for the cookie session store's cookie.  #1046 
0
 
0
 * Added FormTagHelper#image_submit_tag confirm option #784 [Alastair Brunton]
...
405
406
407
408
 
409
410
411
...
413
414
415
416
 
417
418
419
420
421
422
 
423
424
425
426
427
428
429
 
 
430
431
 
432
433
434
435
436
...
405
406
407
 
408
409
410
411
...
413
414
415
 
416
417
418
419
 
 
 
420
421
422
 
 
 
 
 
423
424
425
 
426
427
 
428
429
430
0
@@ -405,7 +405,7 @@ module ActionView
0
       #  # Generates: <input name="create_btn" onclick="new Ajax.Request('/testing/create',
0
       #  #     {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)});
0
       #  #     return false;" type="button" value="Create" />
0
-      #  <%= button_to_remote 'create_btn', 'Create', :url => { :action => 'create' } %>
0
+      #  <%= submit_to_remote 'create_btn', 'Create', :url => { :action => 'create' } %>
0
       #
0
       #  # Submit to the remote action update and update the DIV succeed or fail based
0
       #  # on the success or failure of the request
0
@@ -413,24 +413,18 @@ module ActionView
0
       #  # Generates: <input name="update_btn" onclick="new Ajax.Updater({success:'succeed',failure:'fail'},
0
       #  #      '/testing/update', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)});
0
       #  #      return false;" type="button" value="Update" />
0
-      #  <%= button_to_remote 'update_btn', 'Update', :url => { :action => 'update' },
0
+      #  <%= submit_to_remote 'update_btn', 'Update', :url => { :action => 'update' },
0
       #     :update => { :success => "succeed", :failure => "fail" }
0
       #
0
       # <tt>options</tt> argument is the same as in form_remote_tag.
0
-      #
0
-      # Note: This method used to be called submit_to_remote, but that's now just an alias for button_to_remote
0
-      def button_to_remote(name, value, options = {})
0
+      def submit_to_remote(name, value, options = {})
0
         options[:with] ||= 'Form.serialize(this.form)'
0
 
0
-        options[:html] ||= {}
0
-        options[:html][:type] = 'button'
0
-        options[:html][:onclick] = "#{remote_function(options)}; return false;"
0
-        options[:html][:name] = name
0
-        options[:html][:value] = value
0
+        html_options = options.delete(:html) || {}
0
+        html_options[:name] = name
0
 
0
-        tag("input", options[:html], false)
0
+        button_to_remote(value, options, html_options)
0
       end
0
-      alias_method :submit_to_remote, :button_to_remote
0
 
0
       # Returns '<tt>eval(request.responseText)</tt>' which is the JavaScript function
0
       # that +form_remote_tag+ can call in <tt>:complete</tt> to evaluate a multiple
...
218
219
220
221
222
223
 
 
 
224
225
226
...
218
219
220
 
 
 
221
222
223
224
225
226
0
@@ -218,9 +218,9 @@ class PrototypeHelperTest < PrototypeHelperBaseTest
0
 
0
   end
0
 
0
-  def test_button_to_remote
0
-    assert_dom_equal %(<input name=\"More beer!\" onclick=\"new Ajax.Updater('empty_bottle', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)}); return false;\" type=\"button\" value=\"1000000\" />),
0
-      button_to_remote("More beer!", 1_000_000, :update => "empty_bottle")
0
+  def test_submit_to_remote
0
+    assert_dom_equal %(<input name=\"More beer!\" onclick=\"new Ajax.Updater('empty_bottle', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)});\" type=\"button\" value=\"1000000\" />),
0
+      submit_to_remote("More beer!", 1_000_000, :update => "empty_bottle")
0
   end
0
 
0
   def test_observe_field

Comments