當頁面提交主選項卡(註冊,鎖定,解鎖等)停留在當前的一個,但子選項卡(列表,鎖定,檢出等)進入默認搜索)頁面提交。例如,如果我在列表或鎖定選項卡上進行提交,它將默認爲搜索選項卡。 問題:我必須保持在水平標籤和垂直標籤的軌道,目前我能夠只跟蹤水平製表刷新時保持在同一標籤上(標籤內的標籤)
HTML主要選項卡(水平):
<div id="tabs">
<ul>
<li><a href="#tabs-1">Register</a><div class="hidden_area">Register a device</div></li>
<li><a href="#tabs-2">Lock</a><div class="hidden_area">Lock a device</div></li>
<li><a href="#tabs-3">Unlock</a><div class="hidden_area">Unlock a device</div></li>
<li><a href="#tabs-4">Transfer</a><div class="hidden_area">Transfer device to a new warehouse</div></li>
<li><a href="#tabs-5">Manage Users</a><div class="hidden_area">Change/Add regions to a user</div></li>
<li><a href="#tabs-6">Reporting</a><div class="hidden_area">Reporting Services</div></li>
</ul>
HTML子選項卡(垂直):
<div id="tabs1">
<ul>
<li class="first current"><a href="#tab1">Search</a><div class="hidden_area1">Search a device</div></li>
<li><a href="#tab2">List</a><div class="hidden_area1">List all devices</div></li>
<li><a href="#tab3">Locked</a><div class="hidden_area1">List locked devices</div></li>
<li><a href="#tab4">Checked Out</a><div class="hidden_area1">List checked out devices</div></li>
<li><a href="#tab5">Repair</a><div class="hidden_area1">List repair devices</div></li>
<li class="last"><a href="#tab6">No Check In</a><div class="hidden_area1">Devices checked out but not checked in</div></li>
</ul>
jQuery的主標籤:
var index = 'ui.newTab.index()';
// Define data store name
var dataStore = window.sessionStorage;
var oldIndex = 0;
try {
// getter: Fetch previous value
oldIndex = dataStore.getItem(index);
} catch(e) {}
$("#tabs").tabs({
active: oldIndex,
activate: function(event, ui) {
// Get future value
var newIndex = ui.newTab.parent().children().index(ui.newTab);
// Set future value
try {
dataStore.setItem(index, newIndex);
} catch(e) {}
}
});
jQuery的子選項卡:
$("#tabs1").tabs().addClass("ui-tabs-vertical ui-helper-clearfix");
$("#tabs1 li").removeClass("ui-corner-top").addClass("ui-corner-left");
http://stackoverflow.com/questions/11560613/stay-on-a-current-tab-after-after-submitting-a-form-using-jquery – Ranjan
它的工作對我來說水平選項卡,但相同的邏輯不適用於垂直選項卡。另請注意,我必須跟蹤水平標籤和垂直標籤。 –