Skip to content

Instantly share code, notes, and snippets.

@tallesairan
Last active October 26, 2017 12:57
Show Gist options
  • Save tallesairan/8d864dd9b6f8f21df502e5dea9253013 to your computer and use it in GitHub Desktop.
Save tallesairan/8d864dd9b6f8f21df502e5dea9253013 to your computer and use it in GitHub Desktop.
go to last tab after reload page bootstrap
$(function() {
// for bootstrap 3 use 'shown.bs.tab', for bootstrap 2 use 'shown' in the next line
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
// save the latest tab; use cookies if you like 'em better:
localStorage.setItem('lastTab', $(this).attr('href'));
});
// go to the latest tab, if it exists:
var lastTab = localStorage.getItem('lastTab');
if (lastTab) {
$('[href="' + lastTab + '"]').tab('show');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment