Reputation: 13
Am enjoying my first foray into the world of ember, but have stumbled a bit when doing something relatively simple.
I'm wanting to append a handlebars template of elements using a class tagName: "tr" However dont sometimes the elements get inserted but dont show, and other times its simply a Nx list of and no terminator. If I were to manually add it will output the first row perfectly but then halt..
{{#each App.variantController.content}}
<td class="cen"><input class="variant" id="variant-{{unbound pk}}" type="checkbox"></input></td>
<td class="value">{{sku}}</td>
<td class="value">{{cost}}</td>
{{#each basic_product_options}}
<td class="value">{{content}}</td>
{{/each}}
<td class="value cen">
<a data-toggle="modal" href="#editVariationModal" class="btn btn-mini btn-warning">{% trans 'Edit' %}</a>
<a href="#" class="btn btn-mini disabled pull-right"><i class="icon-resize-vertical"></i></a>
</td>
</tr>
{{/each}}
JavaScript:
App = Em.Application.create();
App.Variant = Em.Object.extend({
pk: null,
cost: null,
sku: null
});
App.variantController = Em.ArrayController.create({
content: [],
init: function() {
variants = eval($('script#data-variant_list').html());
for (var i = 0; i < variants.length; i++) {
this.pushObject(App.Variant.create(variants[i]));
}
}
});
App.VariantView = Em.View.create({
tagName: 'tr',
classNames: ['variant'],
templateName: 'hb-variant-list'
});
App.VariantView.appendTo('#variants-list');
the jsfiddle is here: http://jsfiddle.net/GJASM/
Upvotes: 1
Views: 855
Reputation: 9236
You've got something almost working @ http://jsfiddle.net/MikeAski/qhPLt/
Upvotes: 3