lukeraymonddowning / infinite_scrolling_in_inertia_js

3 stars 6 forks source link

If you have filters data in the URL, filters reset and you receive unfiltered items when you loadMoreItems #7

Open connecteev opened 1 year ago

connecteev commented 1 year ago

Per the thread here: https://laracasts.com/series/infinite-scrolling-in-inertia/episodes/4?reply=23697 If you have filters data in URL, when you loadMoreItems, those filters reset and you receive unfiltered items.

From @lukeraymonddowning 's response, we’ll want to set the URL in the before hook rather than on initial page load so that your URL filters are kept in place.

OrangePixelLtd commented 8 months ago

If I understand this correctly then it's a Laravel Paginate function you need here. You need to add withQueryString() to the end of the query. eg:

$users = User::paginate(15)->withQueryString();

This should preserve all your filter parameters. [https://laravel.com/docs/master/pagination#customizing-pagination-urls](Laravel Docs)