This commit is contained in:
buggyj 2024-04-25 23:52:22 +08:00 committed by GitHub
commit b28d2f098b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -122,8 +122,17 @@ SelectWidget.prototype.setSelectValue = function() {
value = value === undefined ? "" : value;
var select = this.getSelectDomNode();
var values = Array.isArray(value) ? value : $tw.utils.parseStringArray(value);
var child;
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();