Skip to content

Instantly share code, notes, and snippets.

View lyschoening's full-sized avatar

Lars Schöning lyschoening

  • Copenhagen, Denmark
View GitHub Profile
@lyschoening
lyschoening / paginated_collection.js
Created December 2, 2011 10:51 — forked from takinbo/paginated_collection.js
Pagination with Backbone.js & django-tastypie
// includes bindings for fetching/fetched
var PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage', 'filtrate', 'sort_by');
typeof(options) != 'undefined' || (options = {});
typeof(this.limit) != 'undefined' || (this.limit = 20);
typeof(this.offset) != 'undefined' || (this.offset = 0);
typeof(this.filter_options) != 'undefined' || (this.filter_options = {});
typeof(this.sort_field) != 'undefined' || (this.sort_field = '');