From fbb56f7ee80078c6ec1ea3166b2e37d8feff496a Mon Sep 17 00:00:00 2001 From: "Erik St. Martin" Date: Sun, 24 Jan 2010 12:37:26 -0500 Subject: refactoring AjaxHelper a bit so that it calls shared method from JavascriptHelper to add attributes for :confirm --- actionpack/lib/action_view/helpers/ajax_helper.rb | 22 ++++++++++------------ 1 file 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) || {} -- cgit v1.2.3