alfonsobries / vue-tailwind

Vue UI components with configurable classes ready for TailwindCSS
https://www.vue-tailwind.com/
MIT License
2.16k stars 138 forks source link

Pagination in Rich Select #248

Closed eguidotti closed 2 years ago

eguidotti commented 2 years ago

Hi there, and thanks for this great framework!

I'm trying to implement a rich select that pulls the data from an API and displays the results in a dropdown menu. The results can be many and they should be paginated, e.g., with a load-more button or infinite-scroll in the dropdown.

I followed your example here and it works great, but I can't find any example on pagination. From the docs, I read that fetchOptions is a:

Method for fetching the options, receives the query as string and the nextPage if apply

My callback for fetchOptions receives the query but not the nextPage. How should I do to enable pagination (nextPage) in the rich-select? Many thanks!

eguidotti commented 2 years ago

Any hint so far? :(

dasturchiuz commented 2 years ago
 returened_data.hasMorePages = {
                    nextPage: data.current_page + 1
                };
eguidotti commented 2 years ago

Thanks! It seems that the value of nextPage is irrelevant. To turn pagination on, I just set hasMorePages to true

return {results: options, hasMorePages: options.length > 0 ? true : false}

Cheers