我想对这个简单的web app实施分页。
我看到可以使用backbone.paginator,但在使用此组件之前,我想知道实现backbone.js分页的最简单,最干净的方法是什么。
这里有一些代码:
请参阅AppView中的评论
视图
var AppView = Backbone.View.extend({
initialize: function () {
items.fetch(); // <-- now it fetches all the data,
// I would like to set a limit
}
});
该集合
var ItemsCollection = Backbone.Collection.extend({
model: item
模型
var ItemModel = Backbone.Collection.extend({
return ItemModel;
});
答案 0 :(得分:1)
使用items.fetch()
之类的内容代替items.fetchPage({pageSize: 12, pageNumber: 23})
,然后将其作为集合上的方法实现。