我正在尝试让#each
为以下模板工作。已经尝试了一段时间,无法让它发挥作用。不确定我错过了什么。
<script>
$(function () {
var endpoint = "/" + "order/activeholdreasons";
$.get(endpoint, function (data) {
renderHoldReaonsTemplate(data);
});
$("#adminHoldModalHeading").text(adminHoldModalHeadingText);
});
function renderHoldReaonsTemplate(holdReasons) {
var template = $("#holdReasonsTemplate").html();
var compiled = Handlebars.compile(template);
var rendered = compiled({ holdReasons: holdReasons, language: window.language });
$("#holdReasonsContainer").html(rendered);
console.log(rendered);
console.log(template);
}
</script>
<script id="holdReasonsTemplate" type="text/x-handlebars-template">
{{#each holdReasons}}
<div class="row">
<input type="radio" value="{{id}}" /><label>{{text}}</label>
</div>
{{/each}}
</script>