Skip to content

Commit cde4710

Browse files
praneetlokemarcosmoura
authored andcommitted
fix pagination not enabling next button when total changes vuematerial#482. (vuematerial#517)
1 parent 36cd794 commit cde4710

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/components/mdTable/mdTablePagination.vue

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<md-icon>keyboard_arrow_left</md-icon>
1313
</md-button>
1414

15-
<md-button class="md-icon-button md-table-pagination-next" @click.native="nextPage" :disabled="currentSize * currentPage >= totalItems">
15+
<md-button class="md-icon-button md-table-pagination-next" @click.native="nextPage" :disabled="hasMoreItems">
1616
<md-icon>keyboard_arrow_right</md-icon>
1717
</md-button>
1818
</div>
@@ -46,14 +46,28 @@
4646
data() {
4747
return {
4848
subTotal: 0,
49-
currentSize: parseInt(this.mdSize, 10),
50-
currentPage: parseInt(this.mdPage, 10),
51-
totalItems: isNaN(this.mdTotal) ? Number.MAX_SAFE_INTEGER : parseInt(this.mdTotal, 10)
49+
totalItems: 0,
50+
currentPage: 1,
51+
currentSize: 0
5252
};
5353
},
54+
watch: {
55+
mdTotal(val) {
56+
this.totalItems = isNaN(val) ? Number.MAX_SAFE_INTEGER : parseInt(val, 10);
57+
},
58+
mdSize(val) {
59+
this.currentSize = parseInt(this.mdSize, 10);
60+
},
61+
mdPage(val) {
62+
this.currentPage = parseInt(this.mdPage, 10);
63+
}
64+
},
5465
computed: {
5566
lastPage() {
5667
return false;
68+
},
69+
hasMoreItems() {
70+
return this.currentSize * this.currentPage >= this.totalItems;
5771
}
5872
},
5973
methods: {

0 commit comments

Comments
 (0)