Select with store
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.9.0/dijit/themes/claro/claro.css">
<label for="deptSelector">Selector:</label><select id="deptSelector"></select>
<div id="output"></div>
JavaScript
require(['dijit/form/Select',
'dijit/registry',
'dojo/html',
'dojo/store/Memory',
'dojo/domReady!'], function (Select, registry, html, Memory) {
var departments = new Memory({
data: [{
id : 1,
name: "Childcare Department",
email: "[email protected]"
}, {
id : 2,
name: "Health Goods Department",
email: "[email protected]"
}, {
id : 3,
name: "Medicine Department",
email: "[email protected]"
}, {
id : 4,
name: "Customer Service",
email: "[email protected]"
}, {
id : 5,
name: "Other Department",
email: "[email protected]"
}]
}),
deptSelector = new Select({
store: departments,
labelAttr : 'name'
}, 'deptSelector');
deptSelector.on('change', function (value) {
html.set('output', departments.get(deptSelector.get('value')).email);
});
deptSelector.startup();
html.set('output', departments.get(deptSelector.get('value')).email);
});