An open API service indexing awesome lists of open source software.

https://github.com/xerdi/meteor-pager

A bootstrap pager in a Meteor Template
https://github.com/xerdi/meteor-pager

bootstrap meteor pager

Last synced: 3 months ago
JSON representation

A bootstrap pager in a Meteor Template

Awesome Lists containing this project

README

          

# Meteor Pager

A Bootstrap pager in a Meteor Template.

## Installation

Add the package to your project:

```shell
meteor add xerdi:pager
```

## Usage

Here's a minimal example for the `pager` template.
```handlebars


...


```
The pager takes the page and limit as `ReactiveVar`'s and takes the record count as `Number` via a template helper function.

```javascript
Template.myPage.onCreated(function () {
this.data.page = new ReactiveVar(0);
this.data.limit = new ReactiveVar(15);
});

Template.myPage.helpers({
records() {
const {page, limit} = Template.instance().data;
return MyCollection.find({}, {skip: limit.get() * page.get(), limit: limit.get()});
},
recordCount() {
return MyCollection.find({}).count();
}
});
```
The `records` helper reuses the `page` and `limit` to get the actual paged results.

Optionally you can pass a custom array of `limits` to the `pager`.