我想出来了。既然我也这么叫
ajaxLoadVehicleSearchDetailContent
在前向和后向导航中,单击后退时会错误地将项目添加到堆栈中。因此,它将从堆栈中弹出项目,调用函数,然后将其重新添加到堆栈中,除非它是当前选项卡。
我的解决方案为我的
ajaxLoadVehicleSearchDetailContent()
方法如下所示。
function ajaxLoadVehicleSearchDetailContent(mode,backward) {
// Get the mode and link object
var thisMode = mode.toString().toLowerCase();
var thisLink = $('a[data-mode="' + mode + '"]');
// If we're switching to a different tab - continue
if (currentMode != thisMode) {
currentMode = thisMode;
// Get the content via AJAX
$.ajax({
url: "/myAjaxFunctionFileURL",
type: "POST",
data: { method:"getTabContent", mode:thisMode },
success: function(result) {
if (!backward) history.pushState(null, document.title, location.pathname + "#!/detail-mode/" + thisMode);
// Update the content area - fadeOut,replace,fadeIn
$('#contentArea').fadeOut(globalAnimationDuration, function() {
$('#contentArea').html(result).fadeIn(globalAnimationDuration);
$('.nav-link').removeClass('current');
thisLink.addClass('current');
});
}
});
}
}
然后,当我从nav链接调用它时-send false,当我从popstate事件调用它时,我调用true。