Skip to content

Commit

Permalink
Add change event to PaginateLinks
Browse files Browse the repository at this point in the history
  • Loading branch information
TahaSh committed Nov 18, 2016
1 parent 4c47a5d commit dfc50e4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,25 @@ To activate this mode, you just need to specify the limit using the `limit` prop
></paginate-links>
```

### Listening to links @change event

When the current page changes, `PaginateLinks` emits an event called `change` to inform you about that. It also passes the switched page numbers with it, if you need them.

``` html
<paginate-links
for="languages"
@change="onLangsPageChange"
></paginate-links>
```

``` js
methods: {
onLangsPageChange (toPage, fromPage) {
// handle here…
}
}
```

### Paginate container

The default element `vue-paginate` uses for the `<paginate>` container is `UL`. But, of course, you can change it to whatever you want using the `tag` prop. And the same is true for its class using the `class` prop.
Expand Down
5 changes: 4 additions & 1 deletion dist/vue-paginate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* vue-paginate v3.0.0
* vue-paginate v3.1.0
* (c) 2016 Taha Shashtari
* @license MIT
*/
Expand Down Expand Up @@ -5533,6 +5533,9 @@
this.updateListOfPages()
},
deep: true
},
currentPage: function currentPage (toPage, fromPage) {
this.$emit('change', toPage + 1, fromPage + 1)
}
},
methods: {
Expand Down
4 changes: 2 additions & 2 deletions dist/vue-paginate.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-paginate",
"version": "3.0.0",
"version": "3.1.0",
"description": "A simple vue.js plugin to paginate data",
"main": "dist/vue-paginate.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions src/components/PaginateLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export default {
this.updateListOfPages()
},
deep: true
},
currentPage (toPage, fromPage) {
this.$emit('change', toPage + 1, fromPage + 1)
}
},
methods: {
Expand Down

0 comments on commit dfc50e4

Please sign in to comment.