0
我有我的觀點:預編譯車把模板無法呈現
var ProductsView = Backbone.View.extend({
initialize: function(){
var that = this;
this.collection.fetch({
success: function()
{
console.log("fetcheo");
that.render();
}
});
this.listenTo(this.collection, "reset", this.render);
},
render: function(){
var cats = [];
this.collection.each(function(model)
{
cats.push(model.get('familia'));
});
this.cats = _.uniq(cats, false);
console.log(this.cats) // It returns ["VINOS", "CERVEZA", "BOTANA"]
this.$el.html(Handlebars.templates.products(this.cats));
return this;
}
});
這是預編譯的車把模板:
<h1>Y LOS MODELOS SON</h1>
<ul>
{{#each cats}}
<li>
{{this}}
</li>
{{/each}}
</ul>
不過,這並不呈現this.cats陣列; 這不是一個收集問題()我已經修復了一個早期的問題。 感謝您的幫助......
感謝名單了很多!!!! –