If you’re using Yii2 Gridview with tabs and notice that when the user filters the results, posting the page goes to the wrong tab.
This solution worked great for me:
$(document).ready(function() {
$('a[data-toggle=\"tab\"]').on('show.bs.tab', function (e) {
localStorage.setItem('lastTab', $(this).attr('href'));
});
var lastTab = localStorage.getItem('lastTab');
if (lastTab) {
$('[href=\"' + lastTab + '\"]').tab('show');
}
});