有没有办法禁用dojox.mobile.Switch使其可见但变灰且不可点击/不可触摸?我在标准 API 文档中看不到任何内容。
编辑:我应该补充一点,我正在使用 Dojo 1.7。
有没有办法禁用dojox.mobile.Switch使其可见但变灰且不可点击/不可触摸?我在标准 API 文档中看不到任何内容。
编辑:我应该补充一点,我正在使用 Dojo 1.7。
我今天必须这样做。我扩展了 Switch 模块。对我来说效果很好,但我相信它可以改进。
define([
"dojo/_base/declare",
"dojox/mobile/Switch"
], function(declare, Switch){
return declare("my.package.Switch", [Switch], {
disabled: false,
events: {},
disableSwitch: function() {
//remove events (but hold on to them for later).. there may be a better dojo way of doing this
this.events._onClick = this._onClick;
this.events.onClick = this.onClick;
this.events.onTouchStart = this.onTouchStart;
this.events.onTouchMove = this.onTouchMove;
this._onClick = function(){};
this.onClick = function(){};
this.onTouchStart = function(){};
this.onTouchMove = function(){};
//TODO: better styling to make it look disabled?
// this.domNode.style.opacity = '0.5';
this.domNode.style['-webkit-filter'] = 'grayscale(1)';
this.disabled = true;
},
enableSwitch: function() {
//reattach events
this._onClick = this.events._onClick;
this.onClick = this.events.onClick;
this.onTouchStart = this.events.onTouchStart;
this.onTouchMove = this.events.onTouchMove;
// this.domNode.style.opacity = '1';
this.domNode.style['-webkit-filter'] = 'grayscale(0)';
this.disabled = false;
}
});
});