我有使用 jquery 选项卡功能的 MVC 2 项目。以下版本用于 jquery 和选项卡。
jquery-1.4.4.min.js jquery.tools.min.js 1.2.5
我在每个选项卡上都有表单控件。在 IE 9 中,当我单击特定选项卡上的保存按钮时
- 该选项卡中的信息被发布到数据库中
- 保存后,新信息保留在页面上,这里没有什么奇怪的事情发生
- 当我单击其他选项卡然后返回到我更改信息的选项卡时。它不显示我的更改,而是显示选项卡首次加载到页面时的信息。
- 当我刷新页面时,选项卡显示正确的信息(并且不像 #3 中描述的那样旧)。
因此,缓存在某种程度上不会保留选项卡单击之间的更改。我该如何解决上面 #3 中描述的问题?
html
<script type="text/javascript">
$(document).ready(function () {
JSGlobalVars.TabsAjaxCall('');
});
</script>
<div class="inside">
<div class="indentmenu">
<ul class="tabs">
<li><a id="GeneralInfo" href="/ProfileEditor/GeneralInfo?fice=XXXXXX&random=68564868">General Info</a></li>
<li><a id="Academics" href="/ProfileEditor/Academics?fice=XXXXXX&random=68564868">Academics</a></li>
<li><a id="Admission" href="/ProfileEditor/Admission?fice=XXXXXX&random=68564868">Admission</a></li>
<li><a id="CampusLife" href="/ProfileEditor/CampusLife?fice=XXXXXX&random=68564868">Campus Life</a></li>
<li><a id="CostAid" href="/ProfileEditor/CostAndAid?fice=XXXXXX&random=68564868">Cost & Aid</a></li>
<li><a id="Athletics" href="/ProfileEditor/Athletics?fice=XXXXXX&random=68564868">Athletics</a></li>
<li><a id="AutomatedOnlineSearch" href="/ProfileEditor/AutomatedOnlineSearch?fice=XXXXXX&random=68564868">Automated Online Search</a></li>
</ul>
</div>
<div class="insideContent">
<div class="panes">
<div style="display: block">
</div>
</div>
</div>
</div>
<div class="reset"></div>
</div>
JSGlobalVars
/* tabs handling*/
//pass tab only on load when displaying a specific tab
TabsAjaxCall: function (tabToDisplay) {
//$("ul.tabs").tabs("div.panes > div", { effect: 'ajax' });
$("ul.tabs").tabs("div.panes > div", { effect: 'ajax', history: true,
onBeforeClick: function (event, tabIndex) {
var $tabProgress = $("#tabProgress");
var $currentTab = $("ul.tabs").children('li').eq(tabIndex).children("a");
jLoaderShow($currentTab);
var tabPanes = this.getPanes();
},
onClick: function (event, tabIndex) {
jLoaderHide();
//to display specific tab on load
if (tabToDisplay != "" && typeof tabToDisplay != "undefined") {
JSGlobalVars.TabOnLoadIndexPerPassedValue(tabToDisplay);
//remove tab, we only need it during load and not on subsequest loads
tabToDisplay = "";
}
var tabPanes = this.getPanes();
}
});
},
TabCurrentRefreshCall: function (currentTabIndex) {
if (currentTabIndex == "" || typeof currentTabIndex == "undefined" || currentTabIndex == "undefined" || currentTabIndex <= 0) {
JSGlobalVars.TabsAjaxCall();
} else {
var $currentTab = $("ul.tabs").children('li').eq(currentTabIndex).children("a");
var id = $currentTab.attr("id");
if (id != "")
JSGlobalVars.TabsAjaxCall(id);
else {
//go the tab index route
JSGlobalVars.TabsAjaxCall();
var tabsApi = $("ul.tabs").data("tabs");
tabsApi.click(currentTabIndex);
}
}
},
TabIndexForSelected: function () {
var tabsApi = $("ul.tabs").data("tabs");
var currentTabIndex = tabsApi.getIndex();
return currentTabIndex;
},
TabOnLoadIndexPerPassedValue: function (myTab) {
var tabIndex = "";
if (myTab != '' && typeof myTab != "undefined") {
var isTabIndex = false;
$("ul.tabs").children('li').children("a").each(function (index) {
if (myTab.toLowerCase() == $(this).attr("id").toLowerCase()) {
tabIndex = index;
isTabIndex = true;
return;
}
});
if (isTabIndex) {
var tabsApi = $("ul.tabs").data("tabs");
tabsApi.click(tabIndex);
}
}
},
TabOnloadIndexPerHash: function () {
var tabIndex = "";
var hash = JSGlobalVars.GetHash();
if (hash != '' && hash != 'undefined') {
var isTabIndex = false;
$("ul.tabs").children('li').children("a").each(function (index) {
if (hash.toLowerCase() == $(this).attr("id").toLowerCase()) {
tabIndex = index;
isTabIndex = true;
return;
}
});
if (isTabIndex) {
var tabsApi = $("ul.tabs").data("tabs");
tabsApi.click(tabIndex);
}
}
},
GetHash: function () {
var hash = document.location.hash;
if (hash != '') {
hash = document.location.hash.substr(1, document.location.hash.length);
}
return hash;
}