Skip Navigation

[Resolved] AJAX pagination is clearing filters

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 4 replies, has 2 voices.

Last updated by HarryT902 7 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#480053

Hi all,

I have noticed that flipping back and forth between pages causes my initial Views' filters to clear. When the filters clear, the POST variables that were set by the filters clear, and all posts display.

I have a View setup with

"Pagination enabled with manual transition and AJAX
Display the query in pages, which visitors will switch without reloading the page."

and

"When to update the Views results
Update the View results only when clicking on the search button
Update the Views results without reloading the page"

How can I stop pagination from clearing my filters? I don't even see the event that is causing the filters to be cleared.

Is there some way I can save my filters in a cookie, then re-set the filters from the cookies?

Thanks for any help,
Harry

PS. I am using Views Version 2.2.2

#480241

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

cars.gif

Hi Harry

I tried to reproduce this on a simple test site but couldn't.

See the attached screen recording, where after I have applied a filter (Ford) I am able to page forward and backward and the filter is still set and operable.

Have I understood your issue correctly?

#481544

Hi Nigel,

That's a great .gif and example of the pagination working. Thanks for putting that together.

I did notice that whenever there are more results available, more pages to paginate through, the problem occurs. I believe it's not causing the filters to clear in your example because you are only paginating back and forth through two pages, and the second page is pre-loaded from the initial search. There is a setting in the View under Advanced for "Cache and preload" that says "Pre-load the next and previous pages - avoids loading delays when users move between pages" which has 1 page by default to preload. In your example, page 2 should be preloaded. I believe this is why you were not getting your filters cleared. Can you try on a test site that has more test posts returning, with maybe 4 or 5 pages?

I can direct you to a test site that has this problem. hidden link currently experiences this problem. For example on dev.findcra.com/search try an initial search with the location of "Kentucky." There should be 5 pages and the phrase "Kentucky, United States" should still be in the location search box. Next paginate to either 3, 4, or pg 5. Notice that the phrase "Kentucky, United States" disappears. Upon the 3rd pagination event look to see how many pages return - 10 pages.

Because the filters got cleared, and because on each pagination the View looks to see which filters are set, all the results are returning.

PS.
Sorry that I do not have time this week to setup a clean environment to take out any other plugins I have installed to rule them out and test against.

PPS.
I have come up with a workaround over the weekend for a different search View that I was working on, but was still having the same problem. I save my filters in cookies and after and pagination event re-apply the filters from the cookies. A bit more goes into this solution to account for when a filter gets updated by the user. So regarding this ticket, this issue is still outstanding for me, but not as critical because I have come up with a workaround.

Thanks,
Harry

#481567

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Harry

I added a lot more content for testing so that I was paginating through at least 5 pages after the filter had been applied, and the results were the same.

I notice on your test page where you talk about adding Kentucky that this is in a text search box.

I tried added the same to my test site, and, again, the search term persisted throughout the pagination.

I tried adding a different filter on your test site (for Organization type) which I set to the first option for non-profit and that didn't seem to have the same problem.

I think the best thing would be, when you have time, to try reproducing this with all non-Toolset plugins disabled and on a default theme such as twentyseventeen, and let me know whether the text filter exhibits the issue then or not.

I may then need to take a copy of your site for testing, but I'll wait to hear back from you.

#481614

Okay, thanks Nigel! Since you have tested the problem and have not come up with anything, it is probably something on my site that is causing the issue. For now, I think we can close this ticket, and in the future reopen it or refer back to it.

Thanks again!

Harry

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.