I'm trying to populate a select element with option elements using Meteor TemplateHelpers and Handlebars.
Template
<template name="newTransaction">
...
<select name="productNameSelect">
{{{ getProductOptions }}}
</select>
...
</template>
Helper
Template.newTransaction.getProductOptions = function () {
//Get all products for drop-down
var count = 0;
var optionsHTML = "";
var options = ProductCollection.find({});
options.forEach( function( product )
{
var newOption = "<option value='" + product.productID + "' >" + product.name + "</option>";
optionsHTML += newOption;
++count;
if( count == options.count() )
{
console.log("Products returned for client:" + optionsHTML )
return optionsHTML;
}
});
};
In the browser JavaScript console the correct console log text is printed, but no options in my select list are added to the DOM.
All my other little helper functions work properly, though they are much simpler and might not take as much time. How do I render the option elements correctly?