Add tab position saving to tenderfoot
This commit is contained in:
parent
3980859101
commit
1ffe30fb4b
1 changed files with 22 additions and 0 deletions
|
@ -5,4 +5,26 @@ $(document).ready(function(){
|
|||
$("#viewAllTab").addClass("active");
|
||||
$(".tab-pane").addClass("fade active in");
|
||||
});
|
||||
|
||||
if (location.hash) {
|
||||
$('li[href=\'' + location.hash + '\']').tab('show');
|
||||
}
|
||||
var activeTab = localStorage.getItem('activeTab');
|
||||
if (activeTab) {
|
||||
$('li[href="' + activeTab + '"]').tab('show');
|
||||
}
|
||||
|
||||
$('body').on('click', 'li[data-toggle=\'tab\']', function (e) {
|
||||
e.preventDefault()
|
||||
var tab_name = this.getAttribute('href')
|
||||
localStorage.setItem('activeTab', tab_name)
|
||||
|
||||
$(this).tab('show');
|
||||
return false;
|
||||
});
|
||||
$(window).on('popstate', function () {
|
||||
var anchor = location.hash ||
|
||||
$('li[data-toggle=\'tab\']').first().attr('href');
|
||||
$('li[href=\'' + anchor + '\']').tab('show');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue