jquery - Looping through unique json formatted data in Handlebars JS -
i ran problem attempting loop through json object. attempted made plenty sense , know why not working.
here last attempt made make work.
<script type="text/x-handlebars-template" id="partnertemplate"> {{#each partners}} <div>{{this.name}}</div> {{/each}} </script>
here object i'm trying pull data from.
partners = renderer({ cerner: { name: 'cerner', selected: false }, walmart: { name: 'walmart', selected: false } });
pretty want select name of current object #each iterating through. think this.name return 2 values (cerner, walmart).
i figured out problem based on how data structured. i'm still not sure why "this.name" didn't work figured out way around it. instead of using base objects changed data array of objects.
data = renderer({ partners: [ { name: 'cerner', selected: false }, { name: 'walmart', selected: false } ] });
and html or handbars.js
<script type="text/x-handlebars-template" id="partnertemplate"> {{#each partners}} <div>{{name}}</div> {{/each}} </script>
Comments
Post a Comment