Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap: Tabs inside a modal

Tags:

I made a moda dialogl and now am trying to insert tabs into it, but having trouble getting the tabs to display content. Partial code of the tabs:

http://plnkr.co/edit/eGRmkzDvo4lYGCjzA5q7

How do I place tab pages inside a modal?

like image 743
Darold Davis Avatar asked Feb 07 '13 22:02

Darold Davis


People also ask

How do I add a tab in bootstrap?

To make the tabs toggleable, add the data-toggle="tab" attribute to each link. Then add a .tab-pane class with a unique ID for every tab and wrap them inside a <div> element with class .tab-content .

How do I make bootstrap 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 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 you keep the current tab active on page reload?

Answer: Use the HTML5 localStorage Object In Bootstrap, if you refresh the page the tab is reset to default setting. However, you can use the HTML5 localStorage object to save some parameter for the current tab locally in the browser and get it back to make the last active tab selected on page reload.


2 Answers

http://plnkr.co/edit/Oj681B1YbLU1dJEiWHZp?p=preview

<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script>

<div class="modal-header">
  <button type="button" class="close" data-dismiss="modal">×</button>
  <h3 ng-hide="newUser">Heading</h3>
</div>


<ul class="nav nav-tabs" id="tabContent">
    <li class="active"><a href="#details" data-toggle="tab">Details</a></li>
    <li><a href="#access-security" data-toggle="tab">Access / Security</a></li>
    <li><a href="#networking" data-toggle="tab">Networking</a></li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="details">

            Details tab
       <div class="control-group">
           <label class="control-label">Instance Name</label>
       </div>
    </div>

    <div class="tab-pane" id="access-security">
        content 0
    </div> 
    <div class="tab-pane" id="networking">
        content 1
    </div> 
</div>
like image 154
sujithayur Avatar answered Sep 18 '22 17:09

sujithayur


You are missing the data-toggle attribute:

<li><a href="#details" data-toggle="tab">Details</a></li>

And the active state for whatever tab you want to show up first:

<li class="active"><a href="#details" data-toggle="tab">Details</a></li>
<div class="tab-pane active" id="details">
like image 25
zachzurn Avatar answered Sep 16 '22 17:09

zachzurn