Set the original button value in an attribute of the button when using the :disable_with key with submit_tag

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6270 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2007-02-28 22:18:50 +00:00
parent 62ac3279e8
commit b1ff3b48e2
3 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Set the original button value in an attribute of the button when using the :disable_with key with submit_tag, so that the original can be restored later. [Jamis Buck]
* session_enabled? works with session :off. #6680 [Catfish]
* Added :port and :host handling to UrlRewriter (which unified url_for usage, regardless of whether it's called in view or controller) #7616 [alancfrancis]

View File

@ -142,6 +142,7 @@ module ActionView
if disable_with = options.delete("disable_with")
options["onclick"] = [
"this.setAttribute('originalValue', this.value)",
"this.disabled=true",
"this.value='#{disable_with}'",
"#{options["onclick"]}",

View File

@ -132,7 +132,7 @@ class FormTagHelperTest < Test::Unit::TestCase
def test_submit_tag
assert_dom_equal(
%(<input name='commit' type='submit' value='Save' onclick="this.disabled=true;this.value='Saving...';alert('hello!');return (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit())" />),
%(<input name='commit' type='submit' value='Save' onclick="this.setAttribute('originalValue', this.value);this.disabled=true;this.value='Saving...';alert('hello!');return (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit())" />),
submit_tag("Save", :disable_with => "Saving...", :onclick => "alert('hello!')")
)
end