I have templates below:
<template name="categoryOption">
{{#each category}}
<option value="{{value}}"
{{selectedCategory ../product.category}}>
{{text}}
</option>
{{/each}}
</template>
<template name="sellerEditItem">
<select name="category" id="input_category">
<option value="" disabled>Choose category</option>
{{> categoryOption}}
</select>
</template>
and the following code:
Template.categoryOption.helpers({
selectedCategory: function(category) {
if(category){
return this.value == category ? 'selected':'';
}
},
category: function() {
return [{
value:'books',
text:'Books'
},{
value:'electronics',
text:'Electronics'
},{
value:'furniture',
text:'Furniture'
},{
value:'clothing',
text:'Clothing'
},{
value:'shoes',
text:'Shoes',
},{
value:'kitchen',
text:'Kitchenware'
}];
}
});
My problem is the selectedCategory helper is not being displayed on the selected option. Please help me out on this! Thanks!