Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Changed PrototypeHelper#submit_to_remote to PrototypeHelper#button_to…
…_remote to stay consistent with link_to_remote (submit_to_remote still works as an alias) (clemens) [#8994 status:closed]
  • Loading branch information
dhh committed Jul 9, 2008
1 parent 84af99e commit 6b61e95
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*Edge*

* Changed PrototypeHelper#submit_to_remote to PrototypeHelper#button_to_remote to stay consistent with link_to_remote (submit_to_remote still works as an alias) #8994 [clemens]

* Add :recursive option to javascript_include_tag and stylesheet_link_tag to be used along with :all. #480 [Damian Janowski]

* Disable the Accept header by default [Michael Koziarski]
Expand Down
9 changes: 6 additions & 3 deletions actionpack/lib/action_view/helpers/prototype_helper.rb
Expand Up @@ -397,19 +397,21 @@ def remote_form_for(record_or_name_or_array, *args, &proc)
# # Generates: <input name="create_btn" onclick="new Ajax.Request('/testing/create',
# # {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)});
# # return false;" type="button" value="Create" />
# <%= submit_to_remote 'create_btn', 'Create', :url => { :action => 'create' } %>
# <%= button_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
# #
# # Generates: <input name="update_btn" onclick="new Ajax.Updater({success:'succeed',failure:'fail'},
# # '/testing/update', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)});
# # return false;" type="button" value="Update" />
# <%= submit_to_remote 'update_btn', 'Update', :url => { :action => 'update' },
# <%= button_to_remote 'update_btn', 'Update', :url => { :action => 'update' },
# :update => { :success => "succeed", :failure => "fail" }
#
# <tt>options</tt> argument is the same as in form_remote_tag.
def submit_to_remote(name, value, options = {})
#
# 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 = {})
options[:with] ||= 'Form.serialize(this.form)'

options[:html] ||= {}
Expand All @@ -420,6 +422,7 @@ def submit_to_remote(name, value, options = {})

tag("input", options[:html], false)
end
alias_method :submit_to_remote, :button_to_remote

# Returns '<tt>eval(request.responseText)</tt>' which is the JavaScript function
# that +form_remote_tag+ can call in <tt>:complete</tt> to evaluate a multiple
Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/template/prototype_helper_test.rb
Expand Up @@ -201,9 +201,9 @@ def test_on_callbacks

end

def test_submit_to_remote
def test_button_to_remote
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\" />),
submit_to_remote("More beer!", 1_000_000, :update => "empty_bottle")
button_to_remote("More beer!", 1_000_000, :update => "empty_bottle")
end

def test_observe_field
Expand Down

0 comments on commit 6b61e95

Please sign in to comment.