fix pagination not enabling next button when total changes #482. (#517)

This commit is contained in:
Praneet Loke 2017-02-16 05:47:34 -08:00 committed by Marcos Moura
parent 36cd794ce9
commit cde4710cf0

View file

@ -12,7 +12,7 @@
<md-icon>keyboard_arrow_left</md-icon>
</md-button>
<md-button class="md-icon-button md-table-pagination-next" @click.native="nextPage" :disabled="currentSize * currentPage >= totalItems">
<md-button class="md-icon-button md-table-pagination-next" @click.native="nextPage" :disabled="hasMoreItems">
<md-icon>keyboard_arrow_right</md-icon>
</md-button>
</div>
@ -46,14 +46,28 @@
data() {
return {
subTotal: 0,
currentSize: parseInt(this.mdSize, 10),
currentPage: parseInt(this.mdPage, 10),
totalItems: isNaN(this.mdTotal) ? Number.MAX_SAFE_INTEGER : parseInt(this.mdTotal, 10)
totalItems: 0,
currentPage: 1,
currentSize: 0
};
},
watch: {
mdTotal(val) {
this.totalItems = isNaN(val) ? Number.MAX_SAFE_INTEGER : parseInt(val, 10);
},
mdSize(val) {
this.currentSize = parseInt(this.mdSize, 10);
},
mdPage(val) {
this.currentPage = parseInt(this.mdPage, 10);
}
},
computed: {
lastPage() {
return false;
},
hasMoreItems() {
return this.currentSize * this.currentPage >= this.totalItems;
}
},
methods: {