更新时间:2023-10-06 10:57:46
我认为这种情况对您来说是 http://bugs.dojotoolkit.org/ticket/10594 ,因为它直接处理dijit.form.Select。当然,有几种方法可以解决此问题。
I think the proper fix in this case for you would be http://bugs.dojotoolkit.org/ticket/10594, since it deals directly with dijit.form.Select. Of course, there are a few ways to fix this.
我会放弃第一个。第二种方法和第三种方法相似,因此我将使用第三种方法发布一个简单的解决方法,
I will forgo the first. The the second and the third method are similar, so I will just post a simple fix using the third way,
dijit.form.Select.extend({
_updateSelection: function() {
this.value = this._getValueFromOpts();
var val = this.value;
if(!dojo.isArray(val)){
val = [val];
}
if(val && val[0]){
dojo.forEach(this._getChildren(), function(child){
var isSelected = dojo.some(val, function(v){
return child.option && (v === child.option.value);
});
dojo.toggleClass(child.domNode, this.baseClass + "SelectedOption", isSelected);
dijit.setWaiState(child.domNode, "selected", isSelected);
}, this);
}
}
});
请注意,我没有编写此函数,但我很高兴在源代码中将其the窃为最后一行,则this._handleOnChange(this.value)已删除。
Note that I did not write this function, I happily plagiarized it from the source code with the last line, this._handleOnChange(this.value) removed.
myWidget.attr('value', newValue, false) // should now work without firing onChange.