您好 Dojo 开发人员,我有一个下拉 form.select,它有几个选项,如何设置要选择的选项。假设我想在 select 元素中显示第三个选项。我正在查看 dojo 文档,但没有看到 setSelected() 或类似内容。
谢谢
最佳答案
除了 value 之外,您还需要使用 displayedValue 属性来设置显示的选项。使用类似的东西:
selector.set("displayedValue", "the_text_of_the_option");
或者您可以使用以下方式搜索下拉菜单的基础商店:
selectorStore.fetch({query:{id: value}, onComplete: function (items) {
dojo.forEach(items, function(item){
selector.set("displayedValue", "the_text_of_the_option");
selector.set("value", "the_value_of_the_option");
});
}});
希望对您有所帮助。
关于javascript - 我如何在 Dojo form.select 选项中设置选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12077916/