Skip to content

Commit

Permalink
fixes #833 - only emit per-page event on per page change
Browse files Browse the repository at this point in the history
  • Loading branch information
xaksis committed Mar 28, 2021
1 parent 0d68f79 commit 5b10f89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1103,11 +1103,13 @@ export default {
pageChanged(pagination) {
this.currentPage = pagination.currentPage;
const pageChangedEvent = this.pageChangedEvent();
pageChangedEvent.prevPage = pagination.prevPage;
this.$emit('on-page-change', pageChangedEvent);
if (this.mode === 'remote') {
this.$emit('update:isLoading', true);
if (!pagination.noEmit) {
const pageChangedEvent = this.pageChangedEvent();
pageChangedEvent.prevPage = pagination.prevPage;
this.$emit('on-page-change', pageChangedEvent);
if (this.mode === 'remote') {
this.$emit('update:isLoading', true);
}
}
},
Expand Down
12 changes: 7 additions & 5 deletions src/components/pagination/VgtPagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default {
if (pageNumber > 0 && this.total > this.currentPerPage * (pageNumber - 1)) {
this.prevPage = this.currentPage;
this.currentPage = pageNumber;
if (emit) this.pageChanged();
this.pageChanged(emit);
}
},
Expand All @@ -167,11 +167,13 @@ export default {
},
// Indicate page changing
pageChanged() {
this.$emit('page-changed', {
pageChanged(emit = true) {
const payload = {
currentPage: this.currentPage,
prevPage: this.prevPage,
});
};
if (!emit) payload.noEmit = true;
this.$emit('page-changed', payload);
},
// Indicate per page changing
Expand All @@ -181,7 +183,7 @@ export default {
//* only emit if this isn't first initialization
this.$emit('per-page-changed', { currentPerPage: this.currentPerPage });
}
this.changePage(1, true);
this.changePage(1, false);
},
// Handle per page changing
Expand Down

0 comments on commit 5b10f89

Please sign in to comment.