The problem I'm experiencing in Chrome and Edge:
In Firefox, the table is still sorted by the correct column and is still on the correct page. How can I make Chrome and Edge also behave this way?
I know DataTables has its stateSave
option (documentation and example), but the problem with that is when the user navigates around the site and then clicks a link to go to the page that has the DataTables table, it will put them back into the same state in that scenario too. I only want the user to be put back into the same state if they use their browser's back button.
Based on this post you could clear the saved state when you click on the link that leads you to the page with the table
see example here
$(document).ready(function() {
$('#example').DataTable( {
"paging": true,
"ordering": true,
"info": false,
stateSave: true
} );
} );
$(".table_link").on("click", function(){
$('#example').DataTable().state.clear();
});