我有一个骨干分页器集合:
var ExercisesCollection = Backbone.Paginator.requestPager.extend({
model: ExerciseModel,
paginator_core: {
url: "/exercises"
},
paginator_ui: {
firstPage: 1,
currentPage: 1,
perPage: 10,
totalPages: 10
},
server_api: {
"filter": "",
"categories": "",
"top": function() { return this.perPage; },
"skip": function() { return this.currentPage * this.perPage; }
},
parse: function (response) {
this.totalPages = response.meta.totalPages;
return response.data;
}
});
我在主干视图中使用它,如下所示:
var Exercises = Backbone.View.extend({
initialize: function () {
this.collection = new ExercisesCollection();
this.collection
.on( "reset", this.render, this )
.on( "change", this.render, this);
this.collection.goTo( 1 );
},
render: function() {
alert("bah!");
}
});
通过查看网络活动,我可以看到它正在向服务器发送请求并接收到适当的响应。但是它从不调用渲染函数。重置和更改事件似乎不起作用。
任何想法我做错了什么?
谢谢