mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
refactoring AjaxHelper a bit so that it calls shared method from JavascriptHelper to add attributes for :confirm
This commit is contained in:
committed by
Stefan Penner
parent
463fc71107
commit
fbb56f7ee8
@@ -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) || {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user