Je devais le faire aujourd'hui. J'ai étendu le module Switch. Fonctionne bien pour moi, mais je suis sûr que cela pourrait être amélioré.
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;
}
});
});
Avez-vous trouvé une solution pour cela? J'ai résolu le problème grisé en changeant l'opacité du conteneur mais je ne vois pas comment désactiver le contrôle réel – Mike