Reputation: 121
I have the following code`
{{# each item}}
<p class="center">
<input type="checkbox" checked="checked" id="basiccbox" name={{id}} />
<label for="basiccbox"> </label>
</p>
{{/each}}
Multiple check boxes is now rendered. However, when i click any of the box, only the first check box toggles between the true or false states. This happens because of the
for="basiccbox"
and
id="basiccbox"
i.e all box that is rendered have the same Id. How do i generate unique ids or how does one deal with such a situation.
`
Upvotes: 0
Views: 119
Reputation: 6008
usually you should assign the item._id to id of checkbox tag. below is the code to solve your issue.
{{# each item}}
<p class="center">
<input type="checkbox" checked="checked" id={{_id}} name={{id}} />
<label for="basiccbox"> </label>
</p>
{{/each}}
It is good to bind the document id somewhere for tag element, because you can use the same id to do DB operations as well.
Upvotes: 0