This commit is contained in:
buggyj 2026-01-20 21:19:10 +08:00 committed by GitHub
commit 54e23e6418
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -121,9 +121,18 @@ SelectWidget.prototype.setSelectValue = function() {
if (this.selectMultiple) {
value = value === undefined ? "" : value;
var select = this.getSelectDomNode();
var values = Array.isArray(value) ? value : $tw.utils.parseStringArray(value);
var child,
values = Array.isArray(value) ? value : $tw.utils.parseStringArray(value);
for(var i=0; i < select.children.length; i++){
select.children[i].selected = values.indexOf(select.children[i].value) !== -1
child=select.children[i];
if(child.children.length === 0){
child.selected = values.indexOf(child.value) !== -1
} else {
// grouped options
for(var y=0; y < child.children.length; y++){
child.children[y].selected = values.indexOf(child.children[y].value) !== -1
}
}
}
} else {
var domNode = this.getSelectDomNode();