Backbone with Tastypie – pagination, server-side filtering and sorting


Starting with pagination which is easy. Tastypie already provides that information for you in the “meta” section of response:

You just need to follow the next and previous links. Which I implemented in the fetchNext and fetchPrev methods. Also there is a fetchPage method to fetch a given page. The page links can be generated onRender based on the meta information.

In your view you can just have the following method and will work like a charm. (Example is using marionette but obviously this would work in plain backbone).