我用标签声明了DropDownSelect:
<select id="someId" dojoType="dojox.form.DropDownSelect" >
<option>Loading...</option>
</select>
然后当调用xhr加载函数时,我想删除上面的选项并创建新的“选择选项”,例如。
load: function(response) {
//remove option, but it stays as displayedValue, displayed
dojo.byId("someId").removeChild(dojo.byId("someId").lastChild);
//I would like to show the option below
dijit.byId("someId").addOption({label: "Choose Option", value:"Select"});
//dijit.byId("someId").setAttribute('displayedValue','Select'); // not working
dijit.byId("someId").addOption(response); // add ajax options.
return response;
},
请告诉我如何在DropDownSelect中显示不同的选项???使用版本1.3。
答案 0 :(得分:1)
// 1。 html:定义下拉列表
<select id="ddselect" name="select" dojoType="dojox.form.DropDownSelect">
<option value="none">
Loading...
</option>
</select>
// 2. onLoad handler:
load: function(response) {
// get widget by id
var dd = dijit.byId("ddselect");
// remove loading option
dd.removeOption(0);
// add new option
dd.addOption({ label: 'newValue1', value: 'nv1'});
// or add array of options
dd.addOption([{ label: 'newValue2', value: 'nv2' }, { label: 'newValue3', value: 'nv3'}]);
}