Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6474

Show
Ignore:
Timestamp:
03/27/07 17:53:52 (1 year ago)
Author:
madrobby
Message:

Fix Form.disable to work again on non-form elements. Closes #6887. [Mislav Marohnic]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/prototype/trunk/CHANGELOG

    r6473 r6474  
    11*SVN* 
     2 
     3* Fix Form.disable to work again on non-form elements.  Closes #6887.  [Mislav Marohnić] 
    24 
    35* Fix an issue with String.prototype.endsWith.  Closes #7822.  [altblue] 
  • spinoffs/prototype/trunk/src/form.js

    r6338 r6474  
    5757  disable: function(form) { 
    5858    form = $(form); 
    59     form.getElements().each(function(element) { 
    60       element.blur(); 
    61       element.disabled = 'true'; 
    62     }); 
     59    Form.getElements(form).invoke('disable'); 
    6360    return form; 
    6461  }, 
     
    6663  enable: function(form) { 
    6764    form = $(form); 
    68     form.getElements().each(function(element) { 
    69       element.disabled = ''; 
    70     }); 
     65    Form.getElements(form).invoke('enable'); 
    7166    return form; 
    7267  }, 
  • spinoffs/prototype/trunk/test/unit/form.html

    r6322 r6474  
    185185    }}, 
    186186     
     187    testFormEnabling: function(){ with(this) { 
     188      var form = $('form_focus') 
     189      var input1 = form.focus_disabled 
     190      var input2 = form.focus_text 
     191       
     192      assert(input1.disabled) 
     193      assert(!input2.disabled) 
     194       
     195      form.disable() 
     196      assert(input1.disabled) 
     197      assert(input2.disabled) 
     198       
     199      form.enable() 
     200      assert(!input1.disabled) 
     201      assert(!input2.disabled) 
     202       
     203      input1.disable() 
     204      assert(input1.disabled) 
     205       
     206      // non-form elements: 
     207      var fieldset = $('form_fieldset') 
     208      var fields = fieldset.immediateDescendants() 
     209      assert(fields.all(function(select){ return !select.disabled })) 
     210       
     211      Form.disable(fieldset) 
     212      assert(fields.all(function(select){ return select.disabled })) 
     213       
     214      Form.enable(fieldset) 
     215      assert(fields.all(function(select){ return !select.disabled })) 
     216    }}, 
     217     
    187218    testFormElementEnabling: function(){ with(this) { 
    188219      assert($('input_disabled').disabled);