Reputation: 1277
I have DropDownSelect declared with tags:
<select id="someId" dojoType="dojox.form.DropDownSelect" >
<option>Loading...</option>
</select>
Then when xhr load function is called I would like to remove the option above and create the new one "Choose Option", for example.
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;
},
Please, tell me how to show different option in DropDownSelect??? The version 1.3 is used.
Upvotes: 1
Views: 556
Reputation: 4237
//1. html: define drop down
<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'}]);
}
Upvotes: 1