把手每个助手都不起作用

时间:2018-06-13 13:38:59

标签: javascript templates handlebars.js

我正在尝试让#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>

0 个答案:

没有答案