Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tables inside Twitter bootstrap tabs

I cant seem to get my tables displayed inside Bootstrap tab's, here is a fiddle I think I am making a small error anyone so kind as to point it out? http://jsfiddle.net/NPpHm/

<ul class="nav nav-tabs" id="product-table">
  <li><a href="#1" data-toggle="tab">Grade 1</a></li>
  <li><a href="#2" data-toggle="tab">Grade 2</a></li>
  <li><a href="#3" data-toggle="tab">Grade 3</a></li>
</ul>
<div class="tab-content">
  <div>
    <div class="tab-pane" id="1">
      <table class="table table-condensed table-bordered table-striped volumes">
        <thead>
          <tr>
            <th>Warehouse</th>
            <th>Grain Volume</th>
            <th>Trade Volume</th>
            <th>Direction</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>NFRA MPANDA RUKWA</td>
            <td>487</td>
            <td>487.00</td>
            <td>IN</td>
          </tr>
          <tr>
            <td>COTCORI Cooperative</td>
            <td>113</td>
            <td>113.00</td>
            <td>IN</td>
          </tr>
          <tr>
            <td>ENAS GBC KIREHE</td>
            <td>131</td>
            <td>131.00</td>
            <td>IN</td>
          </tr>
          <tr>
            <td>Government Procurement and Supply Agent</td>
            <td>453</td>
            <td>453.00</td>
            <td>IN</td>
          </tr>
          <tr>
            <td>Nairobi(test)</td>
            <td>261</td>
            <td>250.00</td>
            <td>IN</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
  <div>
    <div class="tab-pane" id="2">
      <table class="table table-condensed table-bordered table-striped volumes">
        <thead>
          <tr>
            <th>Warehouse</th>
            <th>Grain Volume</th>
            <th>Trade Volume</th>
            <th>Direction</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>National Food Reserve Agency_Manyoni</td>
            <td>172</td>
            <td>172.00</td>
            <td>IN</td>
          </tr>
          <tr>
            <td>Sodea GBC</td>
            <td>471</td>
            <td>20.00</td>
            <td>OUT</td>
          </tr>
          <tr>
            <td>Kivu Maize Factory</td>
            <td>389</td>
            <td>389.00</td>
            <td>IN</td>
          </tr>
          <tr>
            <td>Mombasa Bulk Grain Handlers</td>
            <td>200</td>
            <td>200.00</td>
            <td>IN</td>
          </tr>
          <tr>
            <td>Zwii Enterprises-Muloza</td>
            <td>-47</td>
            <td>47.00</td>
            <td>OUT</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
  <div>
    <div class="tab-pane" id="3">
      <table class="table table-condensed table-bordered table-striped volumes">
        <thead>
          <tr>
            <th>Warehouse</th>
            <th>Grain Volume</th>
            <th>Trade Volume</th>
            <th>Direction</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>COTCORI Cooperative</td>
            <td>93</td>
            <td>93.00</td>
            <td>IN</td>
          </tr>
          <tr>
            <td>SOSOMA GBC KICUKIRO</td>
            <td>-23</td>
            <td>23.00</td>
            <td>OUT</td>
          </tr>
          <tr>
            <td>Shabiby_Indivisual</td>
            <td>270</td>
            <td>270.00</td>
            <td>IN</td>
          </tr>
          <tr>
            <td>Silayo_Union Service Stores</td>
            <td>-38</td>
            <td>38.00</td>
            <td>OUT</td>
          </tr>
          <tr>
            <td>SGR/NFRA VWAWA</td>
            <td>-39</td>
            <td>39.00</td>
            <td>OUT</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>

I have tried to use the prescribed layout, however i have noticed If i remove the table the tabs seem to work fine, using jquery-1.8.3 and Bootstrap v2.2.2

like image 616
Paul Ngumii Avatar asked Jan 14 '13 19:01

Paul Ngumii


2 Answers

You are not following the Twitter Bootstrap layout for tabbable content.

Simplified, your layout looks like this:

<div class="tab-content">
  <div>
    <div class="tab-pane" id="1"/>
  </div>
  <div>
    <div class="tab-pane" id="2"/>
  </div>
  <div>
    <div class="tab-pane" id="3"/>
  </div>
</div>

And it should look like this:

<div class="tab-content">
  <div class="tab-pane" id="1"/>
  <div class="tab-pane" id="2"/>
  <div class="tab-pane" id="3"/>
</div>

See it here.

like image 88
Alexander Avatar answered Nov 06 '22 04:11

Alexander


The problem is the divs between .tab-content and .tab-pane, which apparently break the Bootstrap jQuery. Also, IDs cannot start with a number. (Correction: HTML5 allows this.)

http://jsfiddle.net/33Aby/

<div class="tab-content">
  <div class="tab-pane">
  ...
  </div>
</div>
like image 3
isherwood Avatar answered Nov 06 '22 06:11

isherwood