我正在尝试在集合(Backbone 0.9.2)上的 fetch() 之后执行基本的渲染():
var ProjectListView = Backbone.View.extend({
el: $('#container'),
initialize: function () {
this.collection = new ProjectsCollection();
this.collection.bind("change", _.bind(this.render, this));
this.collection.fetch({ success: function () { console.log("collection fetched"); } });
...
},
render: function () {
console.log("rendered");
...
创建新的视图实例打印出来:
collection fetched
所以 render() 永远不会在 fetch() 之后被调用。我在这里做错了什么?目前没有例外。
任何提示如何在主干中调试这些东西?
附言。考虑到关于 SO 的问题数量,这个特性似乎没有得到很好的记录。