0

I have a listing page which has lots of filters (checkboxes). User selects some of the filters and retrieves results. User can then see the detail of the single result by clicking on any result.

Now what I want is that when the user comes back to the listing page after seeing the detail, it should see the filters intact. The filters could be seen if I comeback through Javascript back function window.history.go(-1);. But the problem is that the filters are not processed.

To process, the submit button needs to be clicked and that's where my problem lies.

How can I trigger my submit button on the previous page?

Here is what I tried. This is called when Back button is clicked from the detail page.

  $('#back-list').on("click", function(e) {

      e.preventDefault();

      window.history.go(-1);

      //This following line is not working
      $('.form-submit').trigger("click");
        return false;

    });

Thanks.

Steve
  • 2,546
  • 8
  • 49
  • 94

2 Answers2

0

You would really probably want to use sessions to store the information (or at least I would).

However, you can use localStorage to hold temporary data.

add something like window.localStorage.setItem('submitform', true); to the back button listener.

Then have some javascript check on the other page window.localStorage.getItem('submitform') == true; and if it does then do window.localStorage.setItem('submitform', false); and submit the existing form.

honerlawd
  • 1,499
  • 11
  • 10
0

I would recommend implementing localstorage.

This might help you out Remember ajax added data when hitting back button

Community
  • 1
  • 1