Alvaro Artiles
Alvaro Artiles

Reputation: 59

dijit.form.ComboBox append options

I cannot solve this:

 $('#To').append('<option value=11>Santa Cruz</option>');

"To" is a dijit.form.ComboBox

It works fine in JQuery but how can I do this in Dojo?

Upvotes: 1

Views: 1592

Answers (1)

Vijay Agrawal
Vijay Agrawal

Reputation: 3821

Is your combobox driven by a datastore? If yes, you can just add the item to the datastore and dojo will take care of updating the ui widget by adding the item to the UI widget. This keeps the data separate from the ui/rendering.

So you could do:

cityDataStore.newItem({ name: 'Santa Cruz', value: 11 });

See related SO question:

dijit.form.filteringselect dynamically change options

Upvotes: 1

Related Questions