I am trying to populate a DOJO select element with JSON data where the item values for value
are expressed by the code
property. Here's an example of what I have:
//require dojo Select
var select = new Select({
name: "stateSelect",
options: [ { display: '1', code: 'TN', label: 'Tennessee' },
{ display: '2',code: 'VA', label: 'Virginia'},
{ display: '3',code: 'WA', label: 'Washington' },
{ display: '4',code: 'FL', label: 'Florida' },
{ display: '5',code: 'CA', label: 'California' }]
}, "stateSelect");
select.startup();
}
Unfortunately, this setup is not working as expected. DOJO seems to require the use of the value
property instead of code
, which is causing issues with my JSON structure. How can I make sure that DOJO interprets my code
tag as its value
? Simply replacing the strings is not an option due to other system requirements relying on the code
value.
You can find more information in the documentation here:
EDIT: IMPORTANT. I have noticed that the tags are specified with quotation marks ("") while my JSON has them without (e.g. "code": "product1" instead of code: "product1"). How should I handle this difference?