有没有一种方法可以禁用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;
}
});
});
关于javascript - 有没有办法禁用dojox.mobile.switch?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11158037/