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
- Host: GitHub
- URL: https://github.com/xerdi/meteor-pager
- Owner: Xerdi
- License: gpl-3.0
- Created: 2022-11-14T11:47:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-21T11:51:41.000Z (about 3 years ago)
- Last Synced: 2025-02-26T23:58:33.553Z (over 1 year ago)
- Topics: bootstrap, meteor, pager
- Language: JavaScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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`.