Skip to content
Browse files

Set the original button value in an attribute of the button when usin…

…g the :disable_with key with submit_tag

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6270 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 62ac327 commit b1ff3b48e27f85bce35857c02d1d90297bb0db5f @jamis jamis committed
View
2 actionpack/CHANGELOG
@@ -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
1 actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -142,6 +142,7 @@ def submit_tag(value = "Save changes", options = {})
if disable_with = options.delete("disable_with")
options["onclick"] = [
+ "this.setAttribute('originalValue', this.value)",
"this.disabled=true",
"this.value='#{disable_with}'",
"#{options["onclick"]}",
View
2 actionpack/test/template/form_tag_helper_test.rb
@@ -132,7 +132,7 @@ def test_stringify_symbol_keys
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

0 comments on commit b1ff3b4

Please sign in to comment.
Something went wrong with that request. Please try again.