Skip to content

Instantly share code, notes, and snippets.

@metalagman
Created November 17, 2015 05:26
Show Gist options
  • Save metalagman/ecc5396fcfd46b5c9778 to your computer and use it in GitHub Desktop.
Save metalagman/ecc5396fcfd46b5c9778 to your computer and use it in GitHub Desktop.
$js = <<<JS
// Change hash for page-reload
$('.nav-tabs a').on('shown.bs.tab', function (e) {
window.location.hash = e.target.hash;
})
// Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#')) {
$('.nav-tabs a[href=#'+url.split('#')[1]+']').tab('show') ;
} else {
$('.nav-tabs a:first').click() ;
}
JS;
$this->registerJs($js);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment