javascript - how to create HTML List templates using handlebarjs -
i try create tree menu templates using handlebarjs .please find below of expected output below link,
but browser view empty. new handlebarjs. please advise how archive output.
html file(index.html)
<script id="sample-template" type="x-handlebars-template"> <!--heading--> <div class="col-md-12"> <span class="fb_options_head">{{label}}</span> </div> <!--list of items--> {{#bin}} <ul> <li><input type="checkbox"/>{{label}} ({{cndocs}})</li> </ul> {{/bin}} </script>
script file(script.js)
$(function () { var sampledata = [{ "label": "heading 1", "bin": [{ "state": "lobbin==text 1", "label": "text 1", "cndocs": 2, "ndocs": 2 }, { "state": "lobbin==text 2", "label": "text 2", "cndocs": 3, "ndocs": 1 }, { "state": "lobbin==text 3", "label": "text 3", "cndocs": 4, "ndocs": 1 }], "bs-id": "lobbin" }, {"statebin": { "label": "state", "bin": [{ "state": "statebin==paragrph 1", "label": "paragrph 1", "ndocs": 1 }, { "state": "statebin==paragrph 2", "label": "paragrph 2", "ndocs": 1 }, { "state": "statebin==paragrph 3", "label": "paragrph 3", "ndocs": 2 }], "bs-id": "statebin" } }]; var thetemplatescript = $("#sample-template").html(); var thetemplate = handlebars.compile (thetemplatescript); $(".shoesnav").append (thetemplate(sampledata)); });
<div class="container-fluid"> <script id="sample-template" type="x-handlebars-template"> {{#each }} <div class="col-md-12"> <span class="fb_options_head">{{label}}</span> </div> <ul> {{#each bin }} <li><input type="checkbox"/>{{label}} ({{cndocs}})</li> {{/each}} </ul> {{/each}} </script> </div> <div class="shoesnav"> </div> </div>
$(function () { var sampledata = [{ "label": "heading 1", "bin": [{ "state": "lobbin==text 1", "label": "text 1", "cndocs": 2, "ndocs": 2 }, { "state": "lobbin==text 2", "label": "text 2", "cndocs": 3, "ndocs": 1 }, { "state": "lobbin==text 3", "label": "text 3", "cndocs": 4, "ndocs": 1 }], "bs-id": "lobbin"}, { "label": "state", "bin": [{ "state": "statebin==paragrph 1", "label": "paragrph 1", "ndocs": 1 }, { "state": "statebin==paragrph 2", "label": "paragrph 2", "ndocs": 1 }, { "state": "statebin==paragrph 3", "label": "paragrph 3", "ndocs": 2 }], "bs-id": "statebin" } ];
Comments
Post a Comment