In firefox 46.0.1, there is only one select element
with some option
elements. The select
value attribute is being changed by a javascript code and as confirmation for that, in the browser inspector window
<select value="G" data-id="someid">
and one of the options is
<option value="G">G please</option>
But in the console:
$('select').first().val()
gives empty string as in ""
and thus the display does not show the selected option as I expect.
And if I issue $('select')[0].value = "R"
, the display responds by showing the correct option value.
Why and how to fix this so that it shows the correct option when the javascript code chnages the value attribute of the select element? Thanks
<template name="select">
<select data-id={{_id}} value={{value}}>
{{#each values}}
<option value={{value}}>{{caption}}</option>
{{/each}}
</select>
</template>
The value is populated by Meteor Template helper.
edit
here is the underlaying data from the helper: "sample"
{
"_id" : "SqNF9wTsbaxEhj5b4",
"element" : "select",
"action" : "action12",
"values" : [
{
"group" : "bCode",
"value" : "G",
"caption" : "Select food type..."
},
{
"group" : "bCode",
"value" : "O",
"caption" : "water"
},
],
"userId" : "uhx7rt",
"createdAt" : 1464135235771,
"value" : "G"
}