GithubHelp home page GithubHelp logo

hozefaj / bootstrap-html5-history-tabs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeffdavidgreen/bootstrap-html5-history-tabs

0.0 2.0 0.0 140 KB

Bootstrap tabs that keep track of the history using the HTML5 History API

License: MIT License

HTML 100.00%

bootstrap-html5-history-tabs's Introduction

Bootstrap HTML5 History Tabs

Bootstrap tabs that keep track of the history using the HTML5 History API

Requires jQuery and Bootstrap Tabs to work.

How to use

Simply target the tabs tabs that you want to keep a history with and call the historyTabs plugin.

$('a[data-toggle="tab"]').historyTabs();

This uses the default bootstrap implementation shown on their site. The links should be page links ('#link') in order for the value to be added to the URL properly. An example of this is below:

<div role="tabpanel">
    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
        <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
        <li role="presentation"><a href="#messages" class="active" aria-controls="messages" role="tab" data-toggle="tab">Messages</a></li>
        <li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li>
    </ul>
    <!-- Tab panes -->
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane" id="home">Home Tab</div>
        <div role="tabpanel" class="tab-pane" id="profile">Profile Tab</div>
        <div role="tabpanel" class="tab-pane active" id="messages">Messages Tab</div>
        <div role="tabpanel" class="tab-pane" id="settings">Settings Tab</div>
    </div>
</div>

When clicking on #settings link, you will see the URL update to be baseurl/#settings. If you have an active tab set, then that tab will begin the history and will be added to the URL immediately. On the load of the page, it will use the hash value in the URL in order to load the correct tab. On back and forward, it will use the current history state in order to load the URL.

bootstrap-html5-history-tabs's People

Contributors

jeffdavidgreen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.