dojox.mobile.Switchを無効にする方法はありますか? 標準 API ドキュメントには何も表示されません。
編集: Dojo 1.7 で作業していることを追加する必要があります。
dojox.mobile.Switchを無効にする方法はありますか? 標準 API ドキュメントには何も表示されません。
編集: Dojo 1.7 で作業していることを追加する必要があります。
私は今日これをしなければなりませんでした。スイッチモジュールを拡張しました。私にとってはうまく機能しますが、改善できると確信しています。
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;
}
});
});