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:38:37 -0700 2008
commit  67d5ac93556dd62fe6d7721a154085f39c919035
tree    259afe95b1eddd0277e50ce1427c676a88dd67ed
parent  b416c6880bba538799513f4afd4125a0be8c2fb5
...
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.