Reload table when user back arrows on browser

Reload table when user back arrows on browser

ArielSAdamsNASAArielSAdamsNASA Posts: 105Questions: 15Answers: 0

Description of problem: I have a datatable of lessons on a private website. The user can click on a lesson to be redirected to page so they can delete the lesson or row. When the user goes back to the table using the back arrow on a browser, the table is not updated so the lesson is still there unless they refresh the page. This confuses some users, because they do not know that the page must be refreshed. Is there a way to update/reload the datatable when the user goes to the table via back arrow?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    This is more of a general JS issue, rather than something specific to DataTables. This SO thread should help - there are a few good examples there.

    Colin

  • ArielSAdamsNASAArielSAdamsNASA Posts: 105Questions: 15Answers: 0

    Ended up using:

    window.addEventListener( "pageshow", function ( event ) {
      var historyTraversal = event.persisted ||
                             ( typeof window.performance != "undefined" &&
                                  window.performance.navigation.type === 2 );
      if ( historyTraversal ) {
        // Handle page restore.
        window.location.reload();
      }
    });
    
Sign In or Register to comment.