Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a Twitter Bootstrap 'nav-tabs' menu without changing the URL - Is it possible?

I am after a nav-tab that does not involve the URL changing but obviously the tabs change and display the relevant information.

I have an angularjs site but whenever the page refreshes it take the user back to the search page. As the normal twitter bootstrap nav-tabs changes the URL I can not use this but it's something I want to do.

Questions are:

  1. Does anyone know a way of doing this using the twitter bootstrap nav-tabs
  2. If not, is there something else I can use which does the same

Below is cut of my code:

    <div class="row" data-ng-if="showcharts">
    <div class="col-md-12">
        <!-- Nav tabs -->
        <ul class="nav nav-tabs" role="tablist">
            <li role="presentation" class="active"><a href="#productBreakdown" role="tab" data-toggle="tab"><span class="tabHeadings">Product breakdown</span></a></li>
            <li role="presentation" style="border-right: 1px solid lightgray; border-left: 1px solid lightgray"><a href="#assetsBreakdown" role="tab" data-toggle="tab"><span class="tabHeadings">Assets Breakdown</span></a></li>
            <li role="presentation"><a href="#nbBreakdown" role="tab" data-toggle="tab"><span class="tabHeadings">New Business Breakdown</span></a></li>
        </ul>
        <!-- Tab panes -->
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane active" id="productBreakdown">
                <donutchart id="product-breakdown" data-options="productbreakdownchart"></donutchart>
            </div>
            <div role="tabpanel" class="tab-pane" id="assetsBreakdown">
                <donutchart id="asset-breakdown" data-options="assetbreakdownchart"></donutchart>
            </div>
            <div role="tabpanel" class="tab-pane" id="messages">TO BE ADDED</div>
        </div>
    </div>
</div>

Each tab will display an informational chart to the user.

like image 730
murday1983 Avatar asked Nov 12 '14 14:11

murday1983


People also ask

How do I create a navigation tab in Bootstrap?

Approach: To create a tabbed navigation menu, create a basic unordered list with list items as links. Then add classes nav and nav-tabs of bootstrap to unordered list and nav-items class to list items. Example 1: HTML.

How do you open a specific tab via an external link?

tab=x (where x=tab number) to the URL to display the specific tab. For example: https://demo.dj-extensions.com/dj-tabs/?tab=4 will open 4th tab on the demo site, you can try changing the number to another one to see how it works.

How do I make my nav tab active?

You can activate a tab or pill navigation without writing any JavaScript by simply specifying data-toggle="tab" or data-toggle="pill" on an element. Adding the nav and nav-tabs classes to the tab ul will apply the Bootstrap tab styling, while adding the nav and nav-pills classes will apply pill styling.

How do I make the first tab active in Bootstrap?

You can activate a tab or pill navigation without writing any JavaScript code — simply specify the data-bs-toggle="tab" on each tab, or data-bs-toggle="pill" on each pill, as well as create a . tab-pane with unique ID for every tab and wrap them in .


1 Answers

As you said in comments url changes due to the href attribute in the <a> tag. But you can leave href blank use data-target="..." attribute instead. So

<a href="#productBreakdown" role="tab" data-toggle="tab"></a>

will be

<a href data-target="#productBreakdown" role="tab" data-toggle="tab"></a>
like image 135
Ivan Buryak Avatar answered Oct 15 '22 12:10

Ivan Buryak