Chapter 10. Paginating Backbone.js Requests and Collections

Pagination is a ubiquitous problem we often find ourselves needing to solve on the Web—perhaps most predominantly when we’re working with service APIs and JavaScript-heavy clients that consume them. It’s also a problem that is often underrefined because most of us consider pagination relatively easy to get right. This isn’t, however, always the case, as pagination tends to get trickier than it initially seems.

Before we dive into solutions for paginating data for your Backbone applications, let’s define exactly what we consider pagination to be.

Pagination is a control system allowing users to browse through pages of search results or any type of content that is continued. Search results are the canonical example, but pagination today is found on news sites, blogs, and discussion boards, often in the form of Previous and Next links. More complete pagination systems offer granular control of the specific pages you can navigate to, giving users more power to find what they are looking for.

It isn’t a problem limited to pages requiring some visual controls for pagination either—sites like Facebook, Pinterest, and Twitter have demonstrated that there are many contexts where infinite paging is also useful. Infinite paging is, of course, when we prefetch (or appear to prefetch) content from a subsequent page and add it directly to the user’s current page, making the experience feel infinite.

Pagination is very context-specific ...

Get Developing Backbone.js Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.