From 9345a116af134e6963cda261c448c9ecdb3832ea 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 15:20:26 -0300 Subject: Add back `:confirm` and change deprecation horizon to 4.1 --- actionpack/lib/action_view/helpers/url_helper.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (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 b4eb3d4826..04d9c69e43 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -160,6 +160,12 @@ module ActionView # completion of the Ajax request and performing JavaScript operations once # they're complete # + # ==== Data attributes + # + # * :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. + # # ==== Examples # Because it relies on +url_for+, +link_to+ supports both older-style controller/action/id arguments # and newer RESTful routes. Current Rails style favors RESTful routes whenever possible, so base @@ -274,6 +280,12 @@ module ActionView # * :form_class - This controls the class of the form within which the submit button will # be placed # + # ==== Data attributes + # + # * :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. + # # ==== Examples # <%= button_to "New", :action => "new" %> # # => "
@@ -623,8 +635,15 @@ 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) + confirm = html_options.delete('confirm') method = html_options.delete('method') + if confirm + ActiveSupport::Deprecation.warn ":confirm option is deprecated and will be removed from Rails 4.1. Use ':data => { :confirm => \'Text\' }' instead" + + html_options["data-confirm"] = confirm + end + add_method_to_attributes!(html_options, method) if method html_options -- cgit v1.2.3