Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor a bit this code to add data-confirm and data-disable-with

  • Loading branch information...
commit 0c824e3cd7a03bab08dd152433ca904e9a2cb2b0 1 parent 1c9022d
@spastorino spastorino authored
View
4 actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -390,7 +390,7 @@ def submit_tag(value = "Save changes", options = {})
end
if confirm = options.delete("confirm")
- add_confirm_to_attributes!(options, confirm)
+ options["data-confirm"] = confirm
end
tag :input, { "type" => "submit", "name" => "commit", "value" => value }.update(options.stringify_keys)
@@ -423,7 +423,7 @@ def image_submit_tag(source, options = {})
options.stringify_keys!
if confirm = options.delete("confirm")
- add_confirm_to_attributes!(options, confirm)
+ options["data-confirm"] = confirm
end
tag :input, { "type" => "image", "src" => path_to_image(source) }.update(options.stringify_keys)
View
16 actionpack/lib/action_view/helpers/url_helper.rb
@@ -591,8 +591,8 @@ def convert_options_to_data_attributes(options, html_options)
confirm = html_options.delete('confirm')
method = html_options.delete('method')
- add_disable_with_to_attributes!(html_options, disable_with) if disable_with
- add_confirm_to_attributes!(html_options, confirm) if confirm
+ html_options["data-disable-with"] = disable_with if disable_with
+ html_options["data-confirm"] = confirm if confirm
add_method_to_attributes!(html_options, method) if method
html_options
@@ -603,17 +603,9 @@ def link_to_remote_options?(options)
options.is_a?(Hash) && options.key?('remote') && options.delete('remote')
end
- def add_confirm_to_attributes!(html_options, confirm)
- html_options["data-confirm"] = confirm if confirm
- end
-
- def add_disable_with_to_attributes!(html_options, disable_with)
- html_options["data-disable-with"] = disable_with if disable_with
- end
-
def add_method_to_attributes!(html_options, method)
- html_options["rel"] = "nofollow" if method && method.to_s.downcase != "get"
- html_options["data-method"] = method if method
+ html_options["rel"] = "nofollow" if method.to_s.downcase != "get"
+ html_options["data-method"] = method
end
def options_for_javascript(options)
Please sign in to comment.
Something went wrong with that request. Please try again.