I'm trying to create an html dropdown menu using meteor.
I create a select element, then using helpers try to list province names in the dropdown. Here's the main.html
<template name="signup">
<select>
{{#each province}}
{{> provinceTemplate}}
{{/each}}
</select>
</template>
<template name="provinceTemplate">
<option>{{provinceName}}</option>
</template>
And this is main.js
Template.body.helpers({
province:[
{provinceName: 'Tehran'},
{provinceName: 'Isfahan'},
{provinceName: 'Yazd'},
{provinceName: 'Shiraz'},
{provinceName: 'Kerman'},
],
});
I simply use the helper to shape the dropdown.
But when I run it, there's nothing inside the select tag.
Thank you guys...
I found the answer... You shouldn't call a template( {{> TemplateName}} ) in another template... As soon as I took my code out of the first template, it started working. The following code is wrong...
<body>
{{> firstTemplate}}
</body>
<template name="firstTemplate">
...
{{> secondTemplate}}
...
</template>
<template name="secondTemplate">
...
</template>
Whereas the following code works...
<body>
...
{{> secondTemplate}}
...
</body>
<template name="secondTemplate">
...
</template>