我正在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);
}
}
);
});
但我希望当标签发生变化时,网址也会发生变化。
答案 0 :(得分: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'});