From ceeb1c37c2e6c37716ef558039f3b7b79c640f4d Mon Sep 17 00:00:00 2001 From: Praneet Loke Date: Mon, 27 Feb 2017 17:16:04 -0800 Subject: [PATCH] Change subTotal to a computed property. --- src/components/mdTable/mdTablePagination.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/mdTable/mdTablePagination.vue b/src/components/mdTable/mdTablePagination.vue index 357eb08..746b939 100644 --- a/src/components/mdTable/mdTablePagination.vue +++ b/src/components/mdTable/mdTablePagination.vue @@ -46,7 +46,6 @@ }, data() { return { - subTotal: 0, totalItems: 0, currentPage: 1, currentSize: parseInt(this.mdSize, 10) @@ -72,14 +71,16 @@ }, shouldDisable() { return this.currentSize * this.currentPage >= this.totalItems; + }, + subTotal() { + const sub = this.currentPage * this.currentSize; + + return sub > this.mdTotal ? this.mdTotal : sub; } }, methods: { emitPaginationEvent() { if (this.canFireEvents) { - const sub = this.currentPage * this.currentSize; - - this.subTotal = sub > this.mdTotal ? this.mdTotal : sub; this.$emit('pagination', { size: this.currentSize, page: this.currentPage @@ -109,7 +110,6 @@ }, mounted() { this.$nextTick(() => { - this.subTotal = this.currentPage * this.currentSize; this.mdPageOptions = this.mdPageOptions || [10, 25, 50, 100]; this.currentSize = this.mdPageOptions.includes(this.currentSize) ? this.currentSize : this.mdPageOptions[0]; this.canFireEvents = true;