I have multiple views and I want to save state on each one, so the user doesn't have to do the same things again.
On one of them, I have a table and I use the bootstrap-pagination component for pagination, so when the user changes page, I send the request to a server for new data. I am storing sort and filter parameters in Vuex and it works well.
But when I want to save the current page like that, bootstrap-pagination changes it to 1 every time when I change view and go back. Is it possible to prevent that behavior?
Here is code in HTML:
<b-pagination v-if="currentPage!=-1"
v-model="currentPage"
:total-rows="totalRows"
:per-page="perPage"
aria-controls="my-table"
pils
align="center"
class="ml-auto mr-auto"
></b-pagination>
and code in javascript:
data: function () {
return {
...
currentPage: this.$store.state.currentPage,
...
}
},
...
watch: {
currentPage: function(){
this.$store.commit('updateCurrentPage', this.currentPage);
this.getData();
},
}