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

Comparing #2 with #3

Revision #3 was created by Maurizio Domba Cerin Maurizio Domba Cerin on Oct 3, 2016, 12:09:38 PM.

code formating

Content

[...]
```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!.