ivaynberg/select2 — pull request #1475 by LogicAndTrick (2013-06-28 01:52:09+00:00)
Title: Add support for non-infinite-scrolling pagination

Set the "numPages" value in the results to the total number of pages to enable this style of pagination. Takes precedence over the "more" value.

Infinite scrolling is great, but I had a need for explicitly paged and numbered pagination. Final result looks like this:

![select2 pagination](https://f.cloud.github.com/assets/3071180/719668/af6c49c6-df92-11e2-8e65-3e637515b007.png)

The 'Infinite scroll with remote data' example can be modified for explicit pagination by changing the results function like so:
```javascript
function (data, page) {
var numPages = Math.ceil(data.total / 10); // Get the total number of pages
// Set the numPages value to use explicit pagination
return { results: data.movies, numPages: numPages };
}
```