2013-10-19 2 views
0

3 개의 링크가 있고, 2 개는 푸시 스테이트 데이터 1없이 있습니다. 사용자 + 태그 링크에 데이터가 있습니다. 주제가 없습니다. 나는 사용자를 누른 다음 항목을 누른 다음 태그를 누른 다음 주제를 누른 다음 그것은 완벽하게 작동합니다. 사용자를 클릭 한 다음 태그를 클릭하면 마지막 푸시 스테이트 (태그) 만로드됩니다. 만약 내가 태그를 누른 다음 사용자가 다시 그냥 사용자가 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/'); }) 
}); 

답변

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(); }; 
}); 
관련 문제