Fix Form.disable to work again on non-form elements. Closes #6887. [Mislav Marohnic]
This commit is contained in:
parent
fc91a3e456
commit
db2ee67799
@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Fix Form.disable to work again on non-form elements. Closes #6887. [Mislav Marohnić]
|
||||
|
||||
* Fix an issue with String.prototype.endsWith. Closes #7822. [altblue]
|
||||
|
||||
*1.5.1_rc2* (March 12, 2007)
|
||||
|
@ -56,18 +56,13 @@ Form.Methods = {
|
||||
|
||||
disable: function(form) {
|
||||
form = $(form);
|
||||
form.getElements().each(function(element) {
|
||||
element.blur();
|
||||
element.disabled = 'true';
|
||||
});
|
||||
Form.getElements(form).invoke('disable');
|
||||
return form;
|
||||
},
|
||||
|
||||
enable: function(form) {
|
||||
form = $(form);
|
||||
form.getElements().each(function(element) {
|
||||
element.disabled = '';
|
||||
});
|
||||
Form.getElements(form).invoke('enable');
|
||||
return form;
|
||||
},
|
||||
|
||||
|
@ -184,6 +184,37 @@
|
||||
});
|
||||
}},
|
||||
|
||||
testFormEnabling: function(){ with(this) {
|
||||
var form = $('form_focus')
|
||||
var input1 = form.focus_disabled
|
||||
var input2 = form.focus_text
|
||||
|
||||
assert(input1.disabled)
|
||||
assert(!input2.disabled)
|
||||
|
||||
form.disable()
|
||||
assert(input1.disabled)
|
||||
assert(input2.disabled)
|
||||
|
||||
form.enable()
|
||||
assert(!input1.disabled)
|
||||
assert(!input2.disabled)
|
||||
|
||||
input1.disable()
|
||||
assert(input1.disabled)
|
||||
|
||||
// non-form elements:
|
||||
var fieldset = $('form_fieldset')
|
||||
var fields = fieldset.immediateDescendants()
|
||||
assert(fields.all(function(select){ return !select.disabled }))
|
||||
|
||||
Form.disable(fieldset)
|
||||
assert(fields.all(function(select){ return select.disabled }))
|
||||
|
||||
Form.enable(fieldset)
|
||||
assert(fields.all(function(select){ return !select.disabled }))
|
||||
}},
|
||||
|
||||
testFormElementEnabling: function(){ with(this) {
|
||||
assert($('input_disabled').disabled);
|
||||
$('input_disabled').enable();
|
||||
|
Loading…
Reference in New Issue
Block a user