I use ractive.js to bind a selectbox. I should submit the id of option to server, so I use id and name. But for displaying, I should show the text of option.
<select value='{{selectedCountry}}'>
{{#countries}}
<option value='{{id}}'>{{name}}</option>
{{/countries}}
</select>
ractive = new Ractive({
el: myContainer,
template: myTemplate,
data: {
countries: [
{ id: 1, name: 'Afghanistan' },
{ id: 2, name: 'Albania' },
{ id: 3, name: 'Algeria' }
]
}
});
But I only can get the id, how to get the text in option?
<div>
{{selectedCountry}}
</div>