0
我有一個骨幹分頁程序集:骨幹分頁程序集不觸發渲染復位
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!");
}
});
通過查看網絡活動,我可以看到它正在向服務器發送請求並收到適當的響應。但它從不調用渲染功能。重置和更改事件似乎不起作用。
任何想法我做錯了什麼?
感謝
this.collection你有沒有定義它? – salexch
是this.collection是Paginator集合的一個實例 – user1031947
.on(「add」,this.render,this)? – salexch