PDA

View Full Version : setDisabled(...) method



jmasyan
16 Mar 2012, 3:35 AM
why themethodis set toa string ("enabled", "disabled"), and not boolead (true/false) ?

chramer
16 Mar 2012, 4:36 AM
I checked documentation.. every setDisabled() method has a boolean parameter..
what method do you mean ? give us a link!

jmasyan
16 Mar 2012, 4:38 AM
i mean source code method setDisabled

chramer
16 Mar 2012, 5:25 AM
couldn't find it! everywhere is boolean! paste some code here..

jmasyan
16 Mar 2012, 6:45 AM
/**
* Enable or disable the component.
* @param {Boolean} disabled True to disable.
*/
setDisabled : function(disabled) {
return this[disabled ? 'disable': 'enable']();
},

chramer
16 Mar 2012, 6:59 AM
it doesn't return a string, but a function


return this[disabled ? 'disable': 'enable']();

so if disabled is true, it will return 'this.disable()', else will return 'this.enable()'

P.S.
this['disable'] is equivalent to this.disable

jmasyan
16 Mar 2012, 11:31 AM
thx. i did't see "()"