Reputation: 161
I am able to disable a text box using mootools but after disabling it I am not able to enable it back. Please see the code underneath.
Here 'mg' is id of a text box.
window.addEvent('domready', function(){
$('mg').setAttribute('disabled','true');
//$('mg').disabled = false this works fine
//does not enable text box
$('mg').setAttribute('disabled','false');
});
Here is jsfiddle link. http://jsfiddle.net/GgyCH/2/ please help me out on this.Thanks
Upvotes: 1
Views: 1519
Reputation: 3502
Javascript 101:
$('mg').setAttribute('disabled', true);
$('mg').removeAttribute('disabled');
Upvotes: 0
Reputation: 14746
Using mootools you can use Element method set, to actually set attributes, like so http://jsfiddle.net/steweb/p6BDb/
js:
var elem = $('mg');
elem.set('disabled','disabled'); //disable
elem.set('disabled',''); //enable
Upvotes: 6
Reputation: 20102
just change the value directly in the attribute of the object
alert($('mg').disabled);
$('mg').disabled = true;
alert( $('mg').disabled);
$('mg').disabled = false;
alert($('mg').disabled);
hope this helps
Upvotes: 0
Reputation: 114377
Use: $('mg').setAttribute('disabled','');
(or just remove the attribute)
"disabled", like "selected" is not a true/false attribute. It should actually be:
$('mg').setAttribute('disabled','disabled');
to set it
Upvotes: 0