javascript - 单击“保存”按钮后如何重定向到同一选项卡

标签 javascript jquery html css

我想在单击提交按钮时打开同一个选项卡,因为我认为我可以通过调用选项卡索引来使选项卡处于事件状态,但我怎样才能实现这一点?

function updatebroker() {
    var result = $("#broker_form").serialize();
    $.ajax({
        type: 'POST',
        url: site_url + "mycontacts/updatebroker",
        data: result,
        success: function(response) {
            $('.insertmessage').attr('class', '').addClass('text-success').html('Updated successfully.').show();
            window.location.href = site_url + 'mycontacts/getcommonlist';
            setTimeout(function() {
                $(".insertmessage").hide();
                window.location.href = site_url + 'mycontacts/getcommonlist';
                $("#tabs").tabs(/* ? ? ? ? ? ? ? ? ? ? ? ? ? */);

            }, 3000);

        }
    });
}
<!-- Added via Snippet -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<ul>
    <li id="client">
        <a data-toggle="tab" href="#commonclientlist">My Clients</a>
    </li>
    <li>
        <a data-toggle="tab" href="#developers">Developers</a>
    </li>
    <li id="brokerheader">
        <a data-toggle="tab" href="#brokers">Brokers</a>
    </li>
    <li>
        <a data-toggle="tab" href="#serviceproviders">My Service Providers</a>
    </li>
</ul>
<div class="tab-content">
    <div id="commonclientlist" class="tab-pane fade ">
        <?php include APPPATH . 'views/client/list_clients.php'; ?>
    </div>
    <div id="developers" class="tab-pane fade">
        <?php include APPPATH . 'views/mycontacts/developerslist.php'; ?>
    </div>
    <div id="brokers" class="tab-pane fade">
        <?php include APPPATH . 'views/mycontacts/brokerslist.php'; ?>
    </div>
    <div id="serviceproviders" class="tab-pane fade">
        <?php include APPPATH . 'views/service/listserviceprovider.php'; ?>
    </div>
</div>

我不知道在 jQuery 代码中的 .tabs(???) 中要写什么。有人可以帮助我吗?

最佳答案

在你的成功回调中这个怎么样?

$('#brokerheader').tab('show');

关于javascript - 单击“保存”按钮后如何重定向到同一选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37960152/

相关文章:

javascript - JS : does using && condition instead of if have optimization influence

javascript - 抓取嵌套 Json 对象深处的数据

javascript - 开放层 3 : how to display only a KML layer

jquery - 隐藏/显示 jQuery UI 工具提示的箭头

javascript - 表单提交后重置 Html 表单并防止用户回来查看提交的数据

javascript - Amcharts - 当图表滚动条滚动时可排序的 div 移动

javascript - 悬停时更改多个元素

html - MathJax 或类似 : render arbitrary HTML element inside expression?

html - Bootstrap 移动菜单 100%

html - CSS三 Angular 形以适应可变大小的div元素