Difference between #2 and #5 of
How to make bootstrap tabs remain active/selected after navigating to different web pages.

Changes

Title unchanged

How to make bootstrap tabs remain active/selected after navigating to different web pages.

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

bootstrap3, tabs, active tabs

Content changed

[...]
```php
<?php $this->registerJs(
'$("document").ready(function(){ if (typeof(Storage) !== "undefined") { var dash_localVar = localStorage.getItem("dash_activ_tab"+getUrlPath()); if(dash_localVar){ $(".dashboard_tabs_cl > li").removeClass("active"); $(".tab-content > div").removeClass("active"); var hrefAttr = "a[href=\'"+dash_localVar+"\']"; if( $(hrefAttr).parent() ){ $(hrefAttr).parent().addClass("active"); $(""+dash_localVar+"").addClass("active"); } } $(".dashboard_tabs_cl a").click(function (e) { //alert(window.location.pathname); e.preventDefault(); localStorage.setItem("dash_activ_tab"+getUrlPath(), $( this ).attr( "href" )); }); function getUrlPath(){ var returnVar = "_indexpg"; var splitStr = window.location.href; var asdf = splitStr.split("?r="); if(asdf[1]){ var furthrSplt = asdf[1].split("&"); if(furthrSplt[0]){ returnVar = furthrSplt[0]; }else{ returnVar = asdf[1]; } } return returnVar; } }'
 
}
 
});'
 
); ?> ``` Done!.
1 0
3 followers
Viewed: 16 819 times
Version: 2.0
Category: Tutorials
Written by: emrald
Last updated by: emrald
Created on: Oct 3, 2016
Last updated: 7 years ago
Update Article

Revisions

View all history