diff options
author | Erik St. Martin <alakriti@gmail.com> | 2010-01-24 12:37:26 -0500 |
---|---|---|
committer | Stefan Penner <stefan.penner@gmail.com> | 2010-01-27 12:44:33 -0600 |
commit | fbb56f7ee80078c6ec1ea3166b2e37d8feff496a (patch) | |
tree | a6114d933adcc8495ab3392e2573132183e8fdec /actionpack/lib/action_view | |
parent | 463fc7110755485ee2644690cb87023357f92f9a (diff) | |
download | rails-fbb56f7ee80078c6ec1ea3166b2e37d8feff496a.tar.gz rails-fbb56f7ee80078c6ec1ea3166b2e37d8feff496a.tar.bz2 rails-fbb56f7ee80078c6ec1ea3166b2e37d8feff496a.zip |
refactoring AjaxHelper a bit so that it calls shared method from JavascriptHelper to add attributes for :confirm
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/ajax_helper.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/actionpack/lib/action_view/helpers/ajax_helper.rb b/actionpack/lib/action_view/helpers/ajax_helper.rb index 79e4167292..7e7d4a0557 100644 --- a/actionpack/lib/action_view/helpers/ajax_helper.rb +++ b/actionpack/lib/action_view/helpers/ajax_helper.rb @@ -293,7 +293,11 @@ 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)) + + if confirm = options.delete(:confirm) + add_confirm_to_attributes!(attributes, confirm) + end + attributes.merge!(html_options) content_tag(:a, name, attributes.merge(:href => "#")) @@ -305,7 +309,11 @@ 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)) + + if confirm = options.delete(:confirm) + add_confirm_to_attributes!(attributes, confirm) + end + attributes.merge!(extract_remote_attributes!(options)) tag(:input, attributes) @@ -485,16 +493,6 @@ 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) || {} |