0
對於backbone.js來說是新的,並且在視圖渲染部分有問題。請看下面的代碼,裏面的ul.Html部分下面backbone.js無法渲染裏面的內容ul
<ul id="listview"></ul>
<script type="text/template" id="item">
<li><%= author %></li>
</script>
和JS部分
var book = Backbone.Model.extend();
var cols = Backbone.Collection.extend({
model:book,
url:"http://localhost/bbq/books.php"
});
var col = new cols();
var view = Backbone.View.extend({
el:'#listview',
initialize:function() {
_.bindAll(this, "render");
this.model.fetch({
success:this.render
});
},
render: function() {
_.each(this.model.models, function (mode) {
$(this.el).append(new listUsers({model:mode}).render.el);
},this);
return this;
}
});
var listUsers = Backbone.View.extend({
template: _.template($('#item').html()),
render:function() {
$(this.el).html(this.template(this.model.toJSON()));
return this;
}
});
var vieb = new view({ model : col });
我已經看到了這個'$(this.el).append(新的列表用戶({model:mode})。render.el'模式在很多問題中可能...我可以從你在哪裏學習這個知識..? –