aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2010-01-30 15:28:31 -0600
committerJoshua Peek <josh@joshpeek.com>2010-01-30 15:28:31 -0600
commit779094a6024c762b3dfb60db7efb1d5d7f0c4ddc (patch)
tree95e6f4a7a51a0fc5eb3c07d80b5adffc7a7e94d0 /actionpack
parentb3787643ec4b24b4628e29ebccc5fb517b01b824 (diff)
downloadrails-779094a6024c762b3dfb60db7efb1d5d7f0c4ddc.tar.gz
rails-779094a6024c762b3dfb60db7efb1d5d7f0c4ddc.tar.bz2
rails-779094a6024c762b3dfb60db7efb1d5d7f0c4ddc.zip
Move button_to_remote and submit_to_remote into prototype_legacy_helper
plugin
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb38
-rw-r--r--actionpack/test/template/prototype_helper_test.rb18
2 files changed, 0 insertions, 56 deletions
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index 56a7198792..818412c345 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -102,14 +102,6 @@ module ActionView
:form, :with, :update, :script, :type ]).merge(CALLBACKS)
end
- # Creates a button with an onclick event which calls a remote action
- # via XMLHttpRequest
- # The options for specifying the target with :url
- # and defining callbacks is the same as link_to_remote.
- def button_to_remote(name, options = {}, html_options = {})
- button_to_function(name, remote_function(options), html_options)
- end
-
# Returns a form tag that will submit using XMLHttpRequest in the
# background instead of the regular reloading POST arrangement. Even
# though it's using JavaScript to serialize the form elements, the form
@@ -212,36 +204,6 @@ module ActionView
end
alias_method :form_remote_for, :remote_form_for
- # Returns a button input tag with the element name of +name+ and a value (i.e., display text) of +value+
- # that will submit form using XMLHttpRequest in the background instead of a regular POST request that
- # reloads the page.
- #
- # # Create a button that submits to the create action
- # #
- # # 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' } %>
- #
- # # 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' },
- # :update => { :success => "succeed", :failure => "fail" }
- #
- # <tt>options</tt> argument is the same as in form_remote_tag.
- def submit_to_remote(name, value, options = {})
- options[:with] ||= 'Form.serialize(this.form)'
-
- html_options = options.delete(:html) || {}
- html_options[:name] = name
-
- button_to_remote(value, options, html_options)
- end
-
# 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
# update return document using +update_element_function+ calls.
diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb
index fd868efecd..51a03d25a4 100644
--- a/actionpack/test/template/prototype_helper_test.rb
+++ b/actionpack/test/template/prototype_helper_test.rb
@@ -82,19 +82,6 @@ class PrototypeHelperTest < PrototypeHelperBaseTest
super
end
- def test_button_to_remote
- assert_dom_equal %(<input class=\"fine\" type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true});\" />),
- button_to_remote("Remote outpost", { :url => { :action => "whatnot" }}, { :class => "fine" })
- assert_dom_equal %(<input type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onComplete:function(request){alert(request.reponseText)}});\" />),
- button_to_remote("Remote outpost", :complete => "alert(request.reponseText)", :url => { :action => "whatnot" })
- assert_dom_equal %(<input type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onSuccess:function(request){alert(request.reponseText)}});\" />),
- button_to_remote("Remote outpost", :success => "alert(request.reponseText)", :url => { :action => "whatnot" })
- assert_dom_equal %(<input type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.reponseText)}});\" />),
- button_to_remote("Remote outpost", :failure => "alert(request.reponseText)", :url => { :action => "whatnot" })
- assert_dom_equal %(<input type=\"button\" value=\"Remote outpost\" onclick=\"new Ajax.Request('http://www.example.com/whatnot?a=10&amp;b=20', {asynchronous:true, evalScripts:true, onFailure:function(request){alert(request.reponseText)}});\" />),
- button_to_remote("Remote outpost", :failure => "alert(request.reponseText)", :url => { :action => "whatnot", :a => '10', :b => '20' })
- end
-
def test_form_remote_tag
assert_dom_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">),
form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast })
@@ -195,11 +182,6 @@ class PrototypeHelperTest < PrototypeHelperBaseTest
end
- def test_submit_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)});\" type=\"button\" value=\"1000000\" />),
- submit_to_remote("More beer!", 1_000_000, :update => "empty_bottle")
- end
-
def test_update_page
old_output_buffer = output_buffer