我有我的骨幹路由器:骨幹渲染視圖不顯示...只有在控制檯
var AppRouter = Backbone.Router.extend({
routes:{
"" : "productos",
},
initialize: function(){
this.productoItem = new Producto();
//Crear la vista del detalle de un producto
this.productoItems = new Productos();
this.productoItems.fetch();
this.productosView = new ProductsView({collection: this.productoItems});
},
productos: function(){
$('#app').html(this.productosView.render().el);
//this line seems not to working but putting in a console does the work
}
});
/*********************************/
var app = new AppRouter();
$(function(){
Backbone.history.start();
});
繼承人的看法:
var ProductsView = Backbone.View.extend({
render: function(){
this.$el.html(Handlebars.templates.products(this.collection));
return this;
}
});
最後我的車把模板:
<h1>Y LOS MODELOS SON</h1>
<ul>
{{#each models}}
<li>
{{attributes.familia}}
</li>
{{/each}}
</ul>
因此,當我運行這個應用程序,它只呈現Y LOS MODELOS SON,這意味着 $('#app').html(this.productosView.render().el)
;作品,但沒有完全只有html標記...但是,當我這樣做:
$('#app').html(app.productosView.render().el)
在控制檯它完美... 有人可以解釋我我失去了什麼? 謝謝...
非常感謝!它的工作...不知道在獲取觸發事件... –