1

所以我正在尝试开发一个包含一些嵌套选项卡的网页

这意味着我有两个选项卡,当我按下其中一个选项卡时,我将能够看到两个选项卡。

第一级选项卡对我来说很好用,但是嵌套选项卡不是。这意味着您有两个内容完全不同的选项卡,并且工作正常。

但是当我按下第一个选项卡时的问题(里面有嵌套选项卡的那个)我可以直接看到两个选项卡的内容。虽然我只将其中一个设置为活动。

我试图使没有任何意义的嵌套选项卡处于活动状态,但是我尝试了并且正如预期的那样没有任何区别

这是我的 HTML 页面

<!DOCTYPE html>
<html>
<head>

<title>GitHub Evaluator</title>
<script type='text/javascript' src='js/jquery-2.0.3.min.js'></script>
<script type='text/javascript' src='js/knockout-2.3.0.js'></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/searchModel.js"></script>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="css/sticky-footer.css" rel="stylesheet">
</head>

<body>
<div id="wrap">

<div class="container">
    <div class="page-header">
        <h1>GitHub Evaluator</h1>
    </div>


    <!-- Search Form -->
    <div class="row well" id="masterScope">
        <form class="form-inline">
                <label>Repo name:</label>
                <input data-bind="value: repoName" type="text" class="form-control" style="width: 30%" placeholder="Repo name">
                <label>Username:</label>
                <input data-bind="value: userName" type="text" class="form-control" style="width: 30%" placeholder="Username">
                <button data-bind="click: getRepoInfo" class="btn btn-primary">Search</button>
        </form>
    </div>
    <!-- Search Form -->


    <!-- Tabs -->
    <ul class="nav nav-tabs" id="tabs">
        <li><a href="#Repository" data-toggle="tab">Repository</a></li>
        <li><a href="#User" data-toggle="tab">User</a></li>
    </ul>
    <!-- Tabs -->

    <!-- Tab Content -->
    <div class="tab-content">

        <!-- Repo -->
        <div class="tab-pane active" id="Repository">

            <h2 id="falseRepository" class="text-danger">Repo not found!</h2>

            <!-- Repo Content -->
            <dl id="repo" data-bind="with: repository" class="dl-horizontal">

                <!-- Repo Tabs --->
                <ul class="nav nav-tabs" id="repoTabs">
                    <li><a href="#repoInfo" data-toggle="tab">Info</a></li>
                    <li><a href="#repoStats" data-toggle="tab">Stats</a></li>
                </ul>
                <!-- Repo Tabs -->

                <!-- Repo Stats -->
                <div class="tab-pane" id="#repoStats">
                    Hello World
                </div>
                <!-- Repo Stats -->

                <!-- Repo Info -->
                <div class="tab-pane active" id="repoInfo">
                    <dt>Repo ID:</dt>
                    <dd data-bind="text: id"></dd>
                    <dt>Repo Name:</dt>
                    <dd data-bind="text: name"></dd>
                    <span data-bind="with: owner">
                    <dt>Owner Name:</dt>
                    <dd data-bind="text: login"></dd>
                    <dt>Owner URL:</dt>
                    <dd><a data-bind="attr:{href: url, title: url}"><span data-bind="text: url"></span></a></dd>
                    </span>
                    <dt>Private:</dt>
                    <dd data-bind="text: isPrivate"></dd>
                    <dt>URL:</dt>
                    <dd><a data-bind="attr:{href: url, title: url}"><span data-bind="text: url"></span></a></dd>
                    <dt>Created at:</dt>
                    <dd data-bind="text: createdAt"></dd>
                    <dt>Size:</dt>
                    <dd data-bind="text: size"></dd>
                    <dt>Language:</dt>
                    <dd data-bind="text: language"></dd>
                </div>
                <!-- Repo Info -->



            </dl>
            <!-- Repo Content -->
        </div>
        <!-- Repo -->

        <!-- Users -->
        <div class="tab-pane" id="User">

            <h2 id="falseUser" class="text-danger">User not found!</h2>

            <!--User Content-->
            <div class="accordion" id="accordion2">
          <div class="accordion-group">
            <div class="accordion-heading">
              <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
                Collapsible Group Item #1
              </a>
            </div>
            <div id="collapseOne" class="accordion-body collapse in">
              <div class="accordion-inner">
                ...
              </div>
            </div>
          </div>
          <div class="accordion-group">
            <div class="accordion-heading">
              <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
                Collapsible Group Item #2
              </a>
            </div>
            <div id="collapseTwo" class="accordion-body collapse">
              <div class="accordion-inner">
                ...
              </div>
            </div>
          </div>
          <div class="accordion-group">
            <div class="accordion-heading">
              <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseThree">
                Collapsible Group Item #3
              </a>
            </div>
            <div id="collapseThree" class="accordion-body collapse">
              <div class="accordion-inner">
                ...
              </div>
            </div>
          </div>
        </div>
            <!--User Content-->
        </div>
        <!-- Users -->

      </div>
      <!-- Tab Content -->
        </div>
      </div>

<div id="footer">
    <div class="container">
        <p class="text-muted credit">Awesome GitHub Evaluator by Michal, Abdul and Nick</p>
    </div>
</div>
<!--</script>-->
</body>
</html>
4

2 回答 2

2

在您的代码中修复了以下问题:

  1. #从“回购统计”中删除id#repoStats应该是repoStats
  2. 将两个子选项卡“Repo Stats”和“Repo Info”包装在一个<div class="tab-content">

这是一个工作jsFiddle

于 2013-08-08T11:24:13.463 回答
0

尝试#从 repoStats id 中删除 ..

        <!-- Repo Stats -->
        <div class="tab-pane" id="repoStats">
            Hello World
        </div>
        <!-- Repo Stats -->
于 2013-08-08T11:17:28.673 回答