Browse files

refactoring AjaxHelper a bit so that it calls shared method from Java…

…scriptHelper to add attributes for :confirm
  • Loading branch information...
1 parent 463fc71 commit fbb56f7ee80078c6ec1ea3166b2e37d8feff496a @erikstmartin erikstmartin committed with stefanpenner Jan 24, 2010
Showing with 10 additions and 12 deletions.
  1. +10 −12 actionpack/lib/action_view/helpers/ajax_helper.rb
View
22 actionpack/lib/action_view/helpers/ajax_helper.rb
@@ -293,7 +293,11 @@ def link_to_remote(name, options, html_options = {})
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 @@ def link_to_remote(name, options, html_options = {})
# 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 @@ def script_decorator(options)
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) || {}

0 comments on commit fbb56f7

Please sign in to comment.