1

嗨,我在另一个引导选项卡中显示了一个引导选项卡。在此处输入图像描述

我在使用 ajax 请求加载的 html 文件中有这些内容。刷新页面时。如果用户在特定选项卡中说 main2 ->sub2 ,在加载内容后,我想显示相同的 main2->sub2 选项卡而不是 main1->sub1 选项卡

使用 main.html 中的单独按钮触发刷新

main.html

<a onclick="data_reload_refresh()"><button  type="button" class="btn btn-success" id="refresh_button" style="float:right;background-color:#6D6A66;border-color:#312D25;"> Refresh</button> </a>
<#include "./tabs.html">

tabs.html

<html>
<head>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>


</head>
<body>      
<div class="container">

<div class="row">
    <div class="col-md-6" style="width: 100%; margin-left: -18px;">
        <div class="panel with-nav-tabs panel-primary">
            <div class="panel-heading">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#tabone" data-toggle="tab">Main 1</a></li>
                    <li><a href="#tabtwo" data-toggle="tab"> Main 2</a></li>
                </ul>
            </div>
            <div class="panel-body">
                <div class="tab-content">
                    <div class="tab-pane fade in active" id="tabone">
                        <div class="row">
                            <div class="col-md-6" style="width: 100%">
                                <div class="panel with-nav-tabs panel-info">
                                    <div class="panel-heading">
                                        <ul class="nav nav-tabs" style="color: red;">

                                            <li><a href="#tabsub1" data-toggle="tab">sub 1</a></li>
                                            <li><a href="#tabsub2" data-toggle="tab">sub 2</a></li>
                                        </ul>
                                    </div>
                                    <div class="panel-body">
                                        <div class="tab-content">
                                            <div class="tab-pane fade in active" id="tabsub1">1st Tab Sub 1</div>
                                            <div class="tab-pane fade " id="tabsub2">1st Tab Sub 2</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="tab-pane fade " id="tabtwo">
                        <div class="row">
                            <div class="col-md-6" style="width: 100%">
                                <div class="panel with-nav-tabs panel-info">
                                    <div class="panel-heading">
                                        <ul class="nav nav-tabs" style="color: red;">

                                            <li><a href="#tabsub11" data-toggle="tab">sub 1</a></li>
                                            <li><a href="#tabsub22" data-toggle="tab">sub 2</a></li>
                                        </ul>
                                    </div>
                                    <div class="panel-body">
                                        <div class="tab-content">
                                            <div class="tab-pane fade in active" id="tabsub11">2nd Tab Sub 1</div>
                                            <div class="tab-pane fade " id="tabsub22">2nd Tab Sub 2</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</body>
</html>

tabs.html 将由 ajax 请求返回。我想在内部和外部选项卡中保留选项卡,在刷新之前显示,在刷新内容之后。

4

0 回答 0