Ext的Checkbox控件在用鼠标操作时表现正常,但用代码对其赋值时也会触发单击(click)事件处理句柄。虽不知道原作者的设计意图,这在实际应用中会带来问题,至少在我的应用中不希望这样。通过修改解决了问题,因为原作者原本就是要这样的效果,故不称为bug。以下是修改后的代码。
-
Ext.form.Checkbox.prototype.onClick = function(e){
-
if (!this.disabled && !this.readOnly) {
-
this.toggleValue();
-
-
this.fireEvent('check', this, this.checked);
-
if(this.handler){
-
this.handler.call(this.scope || this, this, this.checked);
-
}
-
}
-
e.stopEvent();
-
};
-
-
Ext.form.Checkbox.prototype.setValue = function(v) {
-
this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on');
-
-
if(this.rendered){
-
this.el.dom.checked = this.checked;
-
this.el.dom.defaultChecked = this.checked;
-
this.wrap[this.checked? 'addClass' : 'removeClass'](this.checkedCls);
-
}
-
}
阅读(1374) | 评论(0) | 转发(0) |