TahaSh / vue-paginate

A simple vue.js plugin to paginate data
MIT License
593 stars 103 forks source link

paginated("items") returns 0 despite :list array is non-empty. #123

Open paragdiwan opened 5 years ago

paragdiwan commented 5 years ago

Hi I have developed a search component which calls a 'list' component internally to show a list of results. <list :data="searchResults" /> The data is a computed property on list component which either takes a data from store or from property parameter. When in the context of search , I could see that paginated('items') returns 0 where as data exists in the list binding variable.

How to refresh the paginated() to reflect the correct number of items ?

felipecarmomps commented 4 years ago

I think I'm having a similar issue. My component starts with a ":list" prop assigned to a computed variable that is an empty array from "vuex", after I add the first element to it instead of starting showing the list "paginated()" keeps returning an empty array, I have to refresh the page to "fix" it.

marcioelias commented 4 years ago

I have the same issue.

Looking at the Vue Devtools, I see that the computed property "currentPage" is set to -1. I believe that this is the root cause of the problem.

currentPage:-1
lastPage:2
pageItemsCount:"-9-0 of 20"
spacewaffle commented 4 years ago

I believe the easy fix is to set a watcher on the list, then run this.goToPage(1) after the update to force the current page to 1.

Someone has forked this repo and applied a fix here which works for me: https://github.com/TahaSh/vue-paginate/issues/121#issuecomment-481718494