Forums › Forums › Search & Filter Pro › Browser back and forward buttons do not work in S&F?
Tagged: ajax, history, popstate, replacestate, V3
- This topic has 10 replies, 3 voices, and was last updated 5 years ago by Trevor.
-
Anonymous(Private) May 9, 2019 at 10:43 am #210560
Hi,
Although the browser address bar changes, it appears from the dev console that s&f does not update the window.history state and therefore the back and forward buttons do not work while in the search results page?
I can see from your unminified script at line 4442
history.pushState(null, null, ajax_results_url);
which doesn’t look correct to me and I believe wouldn’t update the window.history state as there is no data in the first passed variable?
At first, I believed it was my pjax implementation causing the problem but after disabling this, the back/forward buttons still do not work in the filter and window.history state is still not updated. Is there a particular reason for this ?
I also cannot see a popstate handler for the browser back/forward in your code either. I currently use pjax by defunkt for the rest of my site and there are some interesting ways to handle the history in this js if you are interested?
I would like to be able to use forward and back buttons and I am attempting to find a way to do this using your js filters i.e sf:ajaxstart etc but if you could help me implement this, it would be appreciated and actually quite necessary for my site.
Many thanks
Ross Moderator(Private) May 9, 2019 at 1:45 pm #210589Hi Sarah
We’ve added this in to v3 and won’t be implementing this in the current version – although to be fair it was long overdue.
Essentially, it can be incredibly complex to implement depending on your display method in the search form settings.
You would need to grab the HTML that gets updated in results area / ajax container, whenever an ajax request is complete, and store that in a variable (or an array).
Then every time the results (and URL) are updated (on the JS event
sf:ajaxfinish
) you would need to push the new results html on the to array.Then you would need to implement some custom JS to replace the results, with the results from the array, whenever the history state is changed.
I hope that gives the general idea, however we don’t intend to support this in the current version as development on this feature is 90% complete for v3.
V3, as an estimate is a few months away, but this deadline has been sliding unfortunately.
Thanks
Ross Moderator(Private) December 12, 2019 at 1:27 pm #228974This reply has been marked as private.Anonymous(Private) December 12, 2019 at 2:10 pm #228984Hi Ross
Many thanks for that.
What is the latest version number as you don’t state it anywhere? If I am behind at all, I will probably renew now anyway as you have said there is better integration with page builders. Does that include Site Origin at all? I have a feeling I’m on the latest version at 2.4.6 as my license only expired end of September 😉
Sarah
-
AuthorPosts