Skip to content

Instantly share code, notes, and snippets.

@PatrickJS
Created February 22, 2014 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatrickJS/9164291 to your computer and use it in GitHub Desktop.
Save PatrickJS/9164291 to your computer and use it in GitHub Desktop.
Paginated Backbone collection
var Paginated = Backbone.Collection.extend({
pagination : function(perPage, page) {
page = page-1;
var collection = this;
collection = _(collection.rest(perPage*page));
collection = _(collection.first(perPage));
return collection.map( function(model) { return model.toJSON() } );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment