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,

http://imgur.com/twqlqgd

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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -