From 31820b9dd60dc94744028b41f818f1fdab36e271 Mon Sep 17 00:00:00 2001
From: Joshua Peek <josh@joshpeek.com>
Date: Sat, 30 Jan 2010 20:22:15 -0600
Subject: Generate UJS code for :disable_with

---
 actionpack/lib/action_view/helpers/form_tag_helper.rb | 11 +----------
 actionpack/lib/action_view/helpers/url_helper.rb      |  4 ----
 2 files changed, 1 insertion(+), 14 deletions(-)

(limited to 'actionpack/lib')

diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 0e034d781a..fb32f78e5b 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -365,15 +365,7 @@ module ActionView
         options.stringify_keys!
 
         if disable_with = options.delete("disable_with")
-          disable_with = "this.value='#{disable_with}'"
-          disable_with << ";#{options.delete('onclick')}" if options['onclick']
-
-          options["onclick"]  = "if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }"
-          options["onclick"] << "else { hiddenCommit = document.createElement('input');hiddenCommit.type = 'hidden';"
-          options["onclick"] << "hiddenCommit.value = this.value;hiddenCommit.name = this.name;this.form.appendChild(hiddenCommit); }"
-          options["onclick"] << "this.setAttribute('originalValue', this.value);this.disabled = true;#{disable_with};"
-          options["onclick"] << "result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());"
-          options["onclick"] << "if (result == false) { this.value = this.getAttribute('originalValue');this.disabled = false; }return result;"
+          options["data-disable-with"] = disable_with if disable_with
         end
 
         if confirm = options.delete("confirm")
@@ -490,7 +482,6 @@ module ActionView
         def sanitize_to_id(name)
           name.to_s.gsub(']','').gsub(/[^-a-zA-Z0-9:.]/, "_")
         end
-
     end
   end
 end
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 9e52275537..7d42a2ef69 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -588,10 +588,6 @@ module ActionView
           html_options["data-method"] = method if method
         end
 
-        def add_disable_with_to_attributes!(html_options, disable_with)
-          html_options["data-disable-with"] = disable_with if disable_with
-        end
-
         def options_for_javascript(options)
           if options.empty?
             '{}'
-- 
cgit v1.2.3