aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/url_helper.rb
diff options
context:
space:
mode:
authorCarlos Galdino + Rafael Mendonça França <rafael.franca+carlos.galdino@plataformatec.com.br>2012-07-21 15:20:26 -0300
committerCarlos Galdino + Rafael Mendonça França <rafael.franca+carlos.galdino@plataformatec.com.br>2012-07-21 15:20:26 -0300
commit9345a116af134e6963cda261c448c9ecdb3832ea (patch)
tree9ddb84ffdf09c799690cf10ec9614bed05c53148 /actionpack/lib/action_view/helpers/url_helper.rb
parentf5d0e3d7605cc05b0fd549d2b89c9d1db48ce093 (diff)
downloadrails-9345a116af134e6963cda261c448c9ecdb3832ea.tar.gz
rails-9345a116af134e6963cda261c448c9ecdb3832ea.tar.bz2
rails-9345a116af134e6963cda261c448c9ecdb3832ea.zip
Add back `:confirm` and change deprecation horizon to 4.1
Diffstat (limited to 'actionpack/lib/action_view/helpers/url_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb19
1 files changed, 19 insertions, 0 deletions
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
+ #
+ # * <tt>:confirm => 'question?'</tt> - 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
# * <tt>:form_class</tt> - This controls the class of the form within which the submit button will
# be placed
#
+ # ==== Data attributes
+ #
+ # * <tt>:confirm</tt> - 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" %>
# # => "<form method="post" action="/controller/new" class="button_to">
@@ -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