(I have asked this in Stack Overflow)
Is it possible to fetch the value of a document’s field, and use it to select an option tag on said document’s template?
Here’s my code:
Template.item.helpers({
boxOptions: function () {
var currenUser = Meteor.userId();
return Boxes.find({ createdBy: currenUser });
}
});
<template name="item">
<div class="item">
<div class="item-content">
<span>{{content}}</span>
</div>
<div class="item-menu">
Box:
<select>
<option value="">None</option>
{{#each boxOptions}}
<option value="{{_id}}">{{name}}</option>
{{/each}}
</select>
<button class="delete-item">Delete</button>
</div>
</div>
</template>
My first thought was to use a helper, much like “checked” in the official todo tutorial, but I don’t know how to pass it the necessary id’s (item and box ids).
How do I solve this?