PDA

View Full Version : [3.3][4.0]Checkbox processes click event even if it has been set to readOnly.



Animal
16 Dec 2010, 5:51 AM
Code has basically this functionality in both versions:



onClick : function(){
if(this.el.dom.checked != this.checked){
this.setValue(this.el.dom.checked);
}
},


Should be



onClick : function(e){
var me = this;
if (me.readOnly) {
e.stopEvent();
} else if (me.el.dom.checked != me.checked) {
me.setValue(me.el.dom.checked);
}
},

steffenk
16 Dec 2010, 3:50 PM
Hi Nige,
what is the reason for "me" var here?
btw - it would be nice if checkboxes would have isChecked method, it's only possible with the DOM object.

Animal
16 Dec 2010, 10:22 PM
me is just short for this.

Probably no saving in this case, but in a large method, it gets closer to halving the bytes used to reference the current object.

Also, it's useful to use in closures generated within a method.