Take the 2008 Git User's Survey and help out! [ hide ]

public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
Ensure proper output when submit_tag is used with :disabled_with. [#388 
state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
scott-stewart (author)
Tue Jul 01 17:36:58 -0700 2008
lifo (committer)
Tue Jul 01 17:39:30 -0700 2008
commit  7378e237342443addb1691795ac9457250b6db1e
tree    5047524787fb95121fccae812f66c9d4d302b659
parent  6f1d827096ad9f1044a6da7141e7ae720a64ec6b
...
348
349
350
 
 
 
351
352
353
354
355
 
356
357
358
...
348
349
350
351
352
353
354
355
356
 
 
357
358
359
360
0
@@ -348,11 +348,13 @@ module ActionView
0
         options.stringify_keys!
0
 
0
         if disable_with = options.delete("disable_with")
0
+ disable_with = "this.value='#{disable_with}'"
0
+ disable_with << ";#{options.delete('onclick')}" if options['onclick']
0
+
0
           options["onclick"] = [
0
             "this.setAttribute('originalValue', this.value)",
0
             "this.disabled=true",
0
- "this.value='#{disable_with}'",
0
- "#{options["onclick"]}",
0
+ disable_with,
0
             "result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit())",
0
             "if (result == false) { this.value = this.getAttribute('originalValue'); this.disabled = false }",
0
             "return result;",
...
222
223
224
 
 
 
 
 
 
 
225
226
227
...
222
223
224
225
226
227
228
229
230
231
232
233
234
0
@@ -222,6 +222,13 @@ class FormTagHelperTest < ActionView::TestCase
0
     )
0
   end
0
 
0
+ def test_submit_tag_with_no_onclick_options
0
+ assert_dom_equal(
0
+ %(<input name='commit' type='submit' value='Save' onclick="this.setAttribute('originalValue', this.value);this.disabled=true;this.value='Saving...';result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue'); this.disabled = false };return result;" />),
0
+ submit_tag("Save", :disable_with => "Saving...")
0
+ )
0
+ end
0
+
0
   def test_submit_tag_with_confirmation
0
     assert_dom_equal(
0
       %(<input name='commit' type='submit' value='Save' onclick="return confirm('Are you sure?');"/>),

Comments

    No one has commented yet.