0

我正在处理一个 asp.net 页面。我为标签添加了一个 jquery 插件。这是基于 html5 的,并且有这样的 html:

 <ul class="nav nav-tabs" id="myTab">
            <li class="active"><a href="#all">All (902)</a></li>
            <li id="tabToday"><a href="#today">Today (111)</a></li>
            <li><a href="#since">Since last visite (432)</a></li>
            <li><a href="#vacancies">Vacancies (92)</a></li>
            <li><a href="#trainings">Trainings (543)</a></li>
            <li><a href="#tenders">Tenders (233)</a></li>
            <li><a href="#scholarships">Scholarships (1)</a></li>
            <li><a href="#other">Other (4)</a></li>
            <li class="pull-right tab-tbilisi"><a class="tab-tbilisi-a" href="#tbilisi">RUSTAVI</a></li>
            <li class="pull-right tab-kataisi"><a class="tab-kataisi-a" href="#kataisi">BATUMI</a></li>
            <li class="pull-right tab-batumi"><a class="tab-batumi-a" href="#batumi">KATAISI</a></li>
            <li class="pull-right tab-rustavi"><a class="tab-rustavi-a" href="#rustavi">TBILISI</a></li>
        </ul>
 <div class="tab-content">
            <div class="tab-pane active" id="all">
                <div class="jobs-table">
jobs listing
  </div>
            </div>

          <div class="tab-pane" id="since">
                Since</div>
            <div class="tab-pane" id="vacancies">
                Vacancies</div>
            <div class="tab-pane" id="trainings">
                Trainings</div>
            <div class="tab-pane" id="tenders">
                Tenders</div>
            <div class="tab-pane" id="scholarships">
                Scholarships</div>
            <div class="tab-pane" id="other">
                Other</div>
            <div class="tab-pane" id="tbilisi">
                Tbilisi</div>
            <div class="tab-pane" id="kataisi">
                Kataisi</div>
            <div class="tab-pane" id="batumi">
                Batumi</div>
            <div class="tab-pane" id="rustavi">
                Rustavi</div>
        </div>
    </div>

单击标题时,此插件会加载 div。我想更改它,以便当用户单击标题时,会在选项卡内容中加载一个新的 asp.net 页面。我不想使用 iframe。我可以使用类似下面的东西,它可以工作:

 $("#tabToday").click(function () {


                $('#today').load('controls/TodaysVacancies.ascx', function (response, status, xhr) {

                    if (status == "error") {
                        var msg = "Sorry but there was an error: ";
                        alert(msg + xhr.status + " " + xhr.statusText);
                    }
                }
             );

            });

But I want then when a tab changes then URL also changes.

4

1 回答 1

0

您可以简单地将href属性设置为您的<a>标签并通过 ajax 加载它

<ul class="css-tabs" id='myTab'>
  <li><a href="ajax1.htm">Tab 1</a></li>
  <li><a href="ajax2.htm">Second tab</a></li>
  <li><a href="ajax3.htm">An ultra long third tab</a></li>
</ul>

<!-- single pane. it is always visible -->
<div class="css-panes">
  <div style="display:block"></div>
</div>

jQuery

$("#myTab").tabs("div.css-panes > div", {effect: 'ajax'});

检查这个

于 2013-10-11T09:43:36.477 回答