我有3个链接,2个没有的pushstate数据1。用户+标签链接有数据,主题不是。如果我点击用户然后主题然后返回或标记然后主题然后回来它工作完美。如果我点击用户然后点击标签然后点击它将只加载最后一个pushstate(标签)。如果我点击标签然后用户然后支持它只是重用用户pushstate。如果我去标签 - >用户 - >主题,回来会转到用户,再回来也会是用户??
$('#changetousers').click(function () {
$('#loadingAjaxs').show(); $('#flubestext').hide();
$('#contentwrap').load('@Url.Action("FollowingUsersDetail", "Following", new {@ajax = "yes"})', function () { $('#loadingAjaxs').hide(); $('#flubestext').show(); window.history.pushState({ "page": "followingusers" }, 'title1', '/users/'); window.onpopstate = function (e) { document.getElementById('changetousers').click(); };
})
});
$('#changetotags').click(function () {
$('#loadingAjaxs').show(); $('#flubestext').hide();
$('#contentwrap').load('@Url.Action("FollowingTagsDetail", "Following", new {@ajax = "yes"})', function () { $('#loadingAjaxs').hide(); $('#flubestext').show(); window.history.pushState({ "page": "followingtags" }, 'title2', '/tags/'); window.onpopstate = function (e) { document.getElementById('changetotags').click(); }; })
});
$('#changetofavorites').click(function () {
$('#loadingAjaxs').show(); $('#flubestext').hide();
$('#contentwrap').load('@Url.Action("FollowingTopicsDetail", "Following", new {@ajax = "yes"})', function () { $('#loadingAjaxs').hide(); $('#flubestext').show(); window.history.pushState(null, 'title', '/favorites/'); })
});
答案 0 :(得分:1)
我认为你甚至用户点击回调pushState
,这就是为什么你不能进入以前的状态。这应该有效:
function loadUserDetails() {
$('#loadingAjaxs').show();
$('#flubestext').hide();
$('#contentwrap').load(
'@Url.Action("FollowingUsersDetail", "Following", new {@ajax = "yes"})',
function () {
$('#loadingAjaxs').hide();
$('#flubestext').show();
});
}
$('#changetousers').click(function () {
loadUserDetails();
window.history.pushState({ "page": "followingusers" }, 'title1', '/users/');
window.onpopstate = function (e) { loadUserDetails(); };
});