ivaynberg/select2 — pull request #2063 by LogicAndTrick (2014-01-21 00:10:07+00:00)
Title: Add support for numbered (non-infinite-scrolling) pagination

As requested in #1475, this has been rebased onto the `4.0-wip` branch.

* Set the `numPages` value in the results to the total number of pages to enable this style of pagination. This takes precedence over the `more` value, so if both keys are included in the results, numbered pagination will be used instead of the infinite scrolling method.
* When this pagination method is active, Page Up and Page Down will jump to the previous and next pages respectively. When Shift is held, they will jump to the first and last pages instead.

The 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 };
}
```