在我的页面中,我有一些标签......但是根据要求,标签显示在靠近中间的位置...因此,标签上方的部分会快速加载并且需要一些时间加载包含标签的部分......
当加载主页面时,标签内的所有页面也会被加载......所以需要一些时间......我怎么能避免这个?...
我的代码:
<div class="ui-tabs" id="tabs" style="width: 97%;display:none;">
<ul class="ui-tabs-nav">
<li id="planDetails-tab"><a id="hrefPlanDetailsid" accesskey="p" href="#divPlanDetailsTab" class="planTabHeader"> Plan Details</a></li>
<li id="testPlan-tab"><a id="hrefTestPlanid" accesskey="t" href="#divTestPlanTab" class="planTabHeader"> Test Plan </a></li>
<li id="serviceArea-tab"><a href="#divServiceAreaTab" accesskey="s" class="planTabHeader">Service Area</a></li>
<li id="rates-tab"><a href="#divRatesTab" accesskey="r" class="planTabHeader"> Rates </a></li>
<li id="benefits-tab"><a href="#divBenefitsTab" accesskey="b" class="planTabHeader"> Benefits </a></li>
<li id="network-tab"><a href="#divNetworkEcpTab" accesskey="n" class="planTabHeader">Network ECP</a></li>
<li id="historical-tab"><a href="#divHistoricalTab" accesskey="h" class="planTabHeader"> Historical </a></li>
<li id="directory-tab"><a href="#divDirectoryTab" accesskey="d" class="planTabHeader"> Directory </a></li>
</ul>
<div id="divPlanDetailsTab" style="width: 100%;">
<fieldset>
<s:include value="PlanDetail.jsp" />
</fieldset>
</div>
<div id="divTestPlanTab" style="width: 100%;">
<fieldset>
<s:include value="TestPlan.jsp" />
</fieldset>
</div>
<div id="divServiceAreaTab"
class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active" style="width: 100%;">
<fieldset>
<s:include value="PlanServiceArea.jsp" />
</fieldset>
</div>
<div id="divRatesTab"
class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active" style="width: 100%;">
<fieldset>
<s:include value="Rates.jsp" />
</fieldset>
</div>
<div id="divBenefitsTab" class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active" style="width: 100%;">
<fieldset>
<s:include value="PlanBenefits.jsp" />
</fieldset>
</div>
<div id="divNetworkEcpTab"
class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active" style="width: 100%;">
<fieldset>
<s:include value="NetworkECP.jsp" />
</fieldset>
</div>
<div id="divHistoricalTab" class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active" style="width: 100%;">
<fieldset>
<s:include value="PlanHistorical.jsp" />
</fieldset>
</div>
<div id="divDirectoryTab"
class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active" style="width: 100%;">
<fieldset>
<s:include value="ProviderDirectory.jsp" />
</fieldset>
</div>
</div>
js file:
$(function() {
$tabs = $("#tabs").tabs();
$tabs.css('display','block');
//Initially hide Test Plan tab
$('ul li#testPlan-tab').hide();
$('#hrefTestPlanid').hide();
$tabs.tabs({
active : function(event, ui) {
}
});
});
答案 0 :(得分:0)
只需使用AJAX方法加载内容:http://jqueryui.com/tabs/#ajax
通过这种方式,您没有加载大量可能永远不会显示的文本或元素
创建目录“ajax”,在特定文件中移动选项卡的代码并定义如下选项卡:
<ul class="ui-tabs-nav">
<li id="planDetails-tab"><a href="ajax/divPlanDetailsTab.php" id="hrefPlanDetailsid" accesskey="p" class="planTabHeader"> Plan Details</a>
</li>
<li id="testPlan-tab"><a href="ajax/divTestPlanTab.php" id="hrefTestPlanid" accesskey="t" class="planTabHeader"> Test Plan </a>
</li>
...
</ul>
<script>
$(function() {
$( "#tabs" ).tabs({
beforeLoad: function( event, ui ) {
ui.panel.html("Loading in progress...");
ui.jqXHR.error(function() {
ui.panel.html(
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
"If this wouldn't be a demo." );
});
}
});
});
</script>