aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorErik St. Martin <alakriti@gmail.com>2010-01-24 09:57:09 -0500
committerStefan Penner <stefan.penner@gmail.com>2010-01-27 12:44:33 -0600
commitc3baf8b767bdfb27b90b2120f9512d9697e5e932 (patch)
tree6fe4e759a02d7bac029e9673597a10ef320aa8f4 /actionpack/lib
parent9ad8d348b52e5603bb2432ee7fe326142ce5084b (diff)
downloadrails-c3baf8b767bdfb27b90b2120f9512d9697e5e932.tar.gz
rails-c3baf8b767bdfb27b90b2120f9512d9697e5e932.tar.bz2
rails-c3baf8b767bdfb27b90b2120f9512d9697e5e932.zip
link_to_remote and button_to_remote now support :confirm
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/ajax_helper.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/ajax_helper.rb b/actionpack/lib/action_view/helpers/ajax_helper.rb
index 06a57efd95..79e4167292 100644
--- a/actionpack/lib/action_view/helpers/ajax_helper.rb
+++ b/actionpack/lib/action_view/helpers/ajax_helper.rb
@@ -293,6 +293,7 @@ module ActionView
attributes = {}
attributes.merge!(:rel => "nofollow") if options[:method] && options[:method].downcase == "delete"
attributes.merge!(extract_remote_attributes!(options))
+ attributes.merge!(extract_confirm_attributes!(options))
attributes.merge!(html_options)
content_tag(:a, name, attributes.merge(:href => "#"))
@@ -304,6 +305,7 @@ module ActionView
# and defining callbacks is the same as link_to_remote.
def button_to_remote(name, options = {}, html_options = {})
attributes = html_options.merge!(:type => "button", :value => name)
+ attributes.merge!(extract_confirm_attributes!(options))
attributes.merge!(extract_remote_attributes!(options))
tag(:input, attributes)
@@ -483,6 +485,16 @@ module ActionView
private
+ def extract_confirm_attributes!(options)
+ attributes = {}
+
+ if options && options[:confirm]
+ attributes["data-confirm"] = options.delete(:confirm)
+ end
+
+ attributes
+ end
+
def extract_remote_attributes!(options)
attributes = options.delete(:html) || {}