Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26891
  • 博文数量: 12
  • 博客积分: 170
  • 博客等级: 入伍新兵
  • 技术积分: 120
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-21 19:12
文章分类

分类: JavaScript

2014-09-08 18:38:19

    Ext的Checkbox控件在用鼠标操作时表现正常,但用代码对其赋值时也会触发单击(click)事件处理句柄。虽不知道原作者的设计意图,这在实际应用中会带来问题,至少在我的应用中不希望这样。通过修改解决了问题,因为原作者原本就是要这样的效果,故不称为bug。以下是修改后的代码。

点击(此处)折叠或打开

  1. Ext.form.Checkbox.prototype.onClick = function(e){
  2.     if (!this.disabled && !this.readOnly) {
  3.         this.toggleValue();

  4.         this.fireEvent('check', this, this.checked);
  5.         if(this.handler){
  6.             this.handler.call(this.scope || this, this, this.checked);
  7.         }
  8.     }
  9.     e.stopEvent();
  10. };

  11. Ext.form.Checkbox.prototype.setValue = function(v) {
  12.     this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on');
  13.     
  14.     if(this.rendered){
  15.         this.el.dom.checked = this.checked;
  16.         this.el.dom.defaultChecked = this.checked;
  17.         this.wrap[this.checked? 'addClass' : 'removeClass'](this.checkedCls);
  18.     }
  19. }

阅读(1374) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~