[Solution] Keep the active filters (while Reset filters set) when using Details view Back button

JTe

New Member
When accessing the full page details view from a filtered list (Filters->Filters = Pop-up, Navigation->Ajaxify = Yes, Links->Ajaxify Links=No) and returning with the "Back" button all the filtering will be lost and the list displayed unfiltered.

This happens because the Back-button jumps to a direct list url and reloads the list and resets all filters.

To resolve this we could set the Back button to history.back when coming from the list page. If the details page is accessed from other locations the old functionality should be kept to make the functionality consistent to end users.

What we can do is after the dom has loaded check if we did land to the Details page from our list url and if so change the Back button to history.back(), otherwise make it a direct link to our list.

This can be done by adding the file (where XX is your Details view number):
Code:
components/com_fabrik/js/details_XX.js

JavaScript:
window.addEvent('domready',function() {
  document.querySelector('button[name=Goback]').onclick = function(evt) {
    evt.preventDefault();  // Cancel the original event
    if(document.referrer.split('/')[2]=='my.domain.com'){
      onclick = window.history.back();
    } else {
      location.href = 'https://my.domain.com/list';
    }
  };
})

The above javascript is triggered after the dom is ready. We will then replace the Back-button with a code that is replacing the original event of the Back-button with our new event. Above we are checking if we are coming from our domain, but you can also check if we come exactly from our list url:
JavaScript:
if(document.referrer=='https://my.domain.com/list')
Then according to from where we landed on the Details page we will select our action -either history.back() or a direct link.
 
Your code may be helpful in special cases.

But
returning with the "Back" button all the filtering will be lost and the list displayed unfiltered
This should only happen if you set "Reset filters" in menu's "Fabrik Options" to YES. With NO it keeps the filters.
 
Yes, I forgot to mention that. I had to set the Reset Filters because of user feedback. Users were getting confused when going around the site and returning to the list menu having still active filters from previous visit on the list page.

By resetting the filters the user will always land on a "clean" filtering when arriving to the list. So now the filters "live" only the time the user is staying on the list and browsing through detail views. If the user decides to go to some other page and then return to the list the filters are reset, but they are not reset if the user is just visiting the details page.
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top