skip to Main Content

I have used search filters on one of my index view page. All the search filers are same for the second page too. I want to have a functionality in which the selected filter values from first page will be retained on the next filters too automatically and I don’t have to select the filters again on the next page.

3

Answers


  1. On the index page you could add the search filters as query params to the url using jQuery.param(). On the next page you can parse and set the params as filters.

    You could also store the values with localStorage.
    The advantage of query params is that you can easily edit, bookmark and share the url. LocalStorage is better for storing large amounts of data. See also this SO answer.

    Login or Signup to reply.
  2. You can use localStorage in index page to store the selected value of the filters and pass it as default value of filters in next pages

    Login or Signup to reply.
  3. sessionStorage.setItem('sample-filter' , filterValue);
    

    you can use sessionStorage in first page . Because The value stored in sessionStorage will be deleted after the refresh.

    after set sessionStorage you can use filter in next page :

    sessionStorage.getItem('sample-filter');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search