diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 54ea93fb7297d..4de93a10c4694 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*Edge*
+* Make PrototypeHelper#submit_to_remote a wrapper around PrototypeHelper#button_to_remote. [Tarmo Tänav]
+
* Set HttpOnly for the cookie session store's cookie. #1046
* Added FormTagHelper#image_submit_tag confirm option #784 [Alastair Brunton]
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index ff41a6d41718c..a3eccc741dbdf 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -405,7 +405,7 @@ def remote_form_for(record_or_name_or_array, *args, &proc)
# # Generates:
- # <%= button_to_remote 'create_btn', 'Create', :url => { :action => 'create' } %>
+ # <%= submit_to_remote 'create_btn', 'Create', :url => { :action => 'create' } %>
#
# # Submit to the remote action update and update the DIV succeed or fail based
# # on the success or failure of the request
@@ -413,24 +413,18 @@ def remote_form_for(record_or_name_or_array, *args, &proc)
# # Generates:
- # <%= button_to_remote 'update_btn', 'Update', :url => { :action => 'update' },
+ # <%= submit_to_remote 'update_btn', 'Update', :url => { :action => 'update' },
# :update => { :success => "succeed", :failure => "fail" }
#
# options argument is the same as in form_remote_tag.
- #
- # Note: This method used to be called submit_to_remote, but that's now just an alias for button_to_remote
- def button_to_remote(name, value, options = {})
+ def submit_to_remote(name, value, options = {})
options[:with] ||= 'Form.serialize(this.form)'
- options[:html] ||= {}
- options[:html][:type] = 'button'
- options[:html][:onclick] = "#{remote_function(options)}; return false;"
- options[:html][:name] = name
- options[:html][:value] = value
+ html_options = options.delete(:html) || {}
+ html_options[:name] = name
- tag("input", options[:html], false)
+ button_to_remote(value, options, html_options)
end
- alias_method :submit_to_remote, :button_to_remote
# Returns 'eval(request.responseText)' which is the JavaScript function
# that +form_remote_tag+ can call in :complete to evaluate a multiple
diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb
index a1f541fd7b67f..d6b86a396460f 100644
--- a/actionpack/test/template/prototype_helper_test.rb
+++ b/actionpack/test/template/prototype_helper_test.rb
@@ -218,9 +218,9 @@ def test_on_callbacks
end
- def test_button_to_remote
- assert_dom_equal %(),
- button_to_remote("More beer!", 1_000_000, :update => "empty_bottle")
+ def test_submit_to_remote
+ assert_dom_equal %(),
+ submit_to_remote("More beer!", 1_000_000, :update => "empty_bottle")
end
def test_observe_field