From 0106e5fe4436df1853a68c0ed792dc0cf3b9e1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Galdino=20+=20Rafael=20Mendon=C3=A7a=20Fran=C3=A7?= =?UTF-8?q?a?= Date: Sat, 21 Jul 2012 16:19:40 -0300 Subject: Add back `:disable_with` and change deprecation horizon to 4.1 --- actionpack/lib/action_view/helpers/url_helper.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view/helpers/url_helper.rb') diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 04d9c69e43..3d86790a8f 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -165,6 +165,10 @@ module ActionView # * :confirm => 'question?' - This will allow the unobtrusive JavaScript # driver to prompt with the question specified. If the user accepts, the link is # processed normally, otherwise no action is taken. + # * :disable_with - Value of this parameter will be + # used as the value for a disabled version of the submit + # button when the form is submitted. This feature is provided + # by the unobtrusive JavaScript driver. # # ==== Examples # Because it relies on +url_for+, +link_to+ supports both older-style controller/action/id arguments @@ -285,6 +289,10 @@ module ActionView # * :confirm - This will use the unobtrusive JavaScript driver to # prompt with the question specified. If the user accepts, the link is # processed normally, otherwise no action is taken. + # * :disable_with - Value of this parameter will be + # used as the value for a disabled version of the submit + # button when the form is submitted. This feature is provided + # by the unobtrusive JavaScript driver. # # ==== Examples # <%= button_to "New", :action => "new" %> @@ -330,11 +338,11 @@ module ActionView # # # <%= button_to('Destroy', 'http://www.example.com', - # :method => "delete", :remote => true, :data => { :confirm' => 'Are you sure?' }) %> + # :method => "delete", :remote => true, :data => { :confirm' => 'Are you sure?', :disable_with => 'loading...' }) %> # # => "
# #
# # - # # + # # # # # #
# #
" @@ -635,6 +643,7 @@ module ActionView html_options = html_options.stringify_keys html_options['data-remote'] = 'true' if link_to_remote_options?(options) || link_to_remote_options?(html_options) + disable_with = html_options.delete("disable_with") confirm = html_options.delete('confirm') method = html_options.delete('method') @@ -646,6 +655,12 @@ module ActionView add_method_to_attributes!(html_options, method) if method + if disable_with + ActiveSupport::Deprecation.warn ":disable_with option is deprecated and will be removed from Rails 4.1. Use ':data => { :disable_with => \'Text\' }' instead" + + html_options["data-disable-with"] = disable_with + end + html_options else link_to_remote_options?(options) ? {'data-remote' => 'true'} : {} -- cgit v1.2.3