Created
February 22, 2014 23:51
-
-
Save PatrickJS/9164291 to your computer and use it in GitHub Desktop.
Paginated Backbone collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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