Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save atilacamurca/cf3fdb9d1cf0eb53c3e27cabf022a91a to your computer and use it in GitHub Desktop.

Select an option

Save atilacamurca/cf3fdb9d1cf0eb53c3e27cabf022a91a to your computer and use it in GitHub Desktop.

Revisions

  1. atilacamurca revised this gist Sep 26, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ $(document).ready(function() {
    });
    // navigate to a tab when the history changes
    window.addEventListener("popstate", function(e) {
    var activeTab = $('[href=' + location.hash + ']');
    var activeTab = $('[href="' + location.hash + '"]');
    if (activeTab.length) {
    activeTab.tab('show');
    } else {
  2. @fzaninotto fzaninotto created this gist May 17, 2012.
    15 changes: 15 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    $(document).ready(function() {
    // add a hash to the URL when the user clicks on a tab
    $('a[data-toggle="tab"]').on('click', function(e) {
    history.pushState(null, null, $(this).attr('href'));
    });
    // navigate to a tab when the history changes
    window.addEventListener("popstate", function(e) {
    var activeTab = $('[href=' + location.hash + ']');
    if (activeTab.length) {
    activeTab.tab('show');
    } else {
    $('.nav-tabs a:first').tab('show');
    }
    });
    });