2011-08-28 5 views
1

jquery.address 플러그인을 사용하여 Ajax를 사용하여 #content를 동적으로로드합니다. 새로운 #content를로드하기 위해 몇 가지 효과를 사용하고 있습니다 (즉, 예전의 #content가 튀어 나오거나 새것이 위로부터 오는 경우 등). 문제가 아닌 것 같습니다.Ajax 주소 남아 있음 스크롤 위치

문제가 있습니다. , Ajax 요청 후 스크롤 위치가 유지되지 않고 페이지가 위로 이동합니다.

거기에 플러그인/soultion이 있습니까? 나는 쿠키에 현재 위치를 저장하고 $ ("html, body")를 사용하는 것을 읽었다. animate ({scrollTop : x}, t); 도움이 될 것이다. 하지만 그보다 더 간단한 방법으로 그 일을 완수 할 수 있습니까?

미리 감사드립니다.

를 해결

마이크

편집 : 솔루션입니다 밖으로 찾을 수는() (.focus을 주석) :

// Selects the proper navigation link 
$('#menu a').each(function() { 
    //console.log($(this).attr('href')); 
    if (($(this).attr('href') == ($.address.state() + event.path)) { 
     //$(this).addClass('selected').focus(); // .focus() needs to be commented out in order to prevent to set the focus back to this class 
     $(this).addClass('selected'); 
    } 
    else { 
     $('#menu ul li').removeClass('current-menu-item'); 
     $(this).removeClass('selected'); 
    } 
}); 
+0

이 항목이 발견되었습니다. http://stackoverflow.com/questions/4284596/jquery-address-page-jump-issue-in-scrolling-scenarios-address-wrap하지만 false를 반환합니다. 나를 위해 작동하지 않습니다. 이것이 address.wrap()로 수행 할 수 있습니까? – Mike

답변

0

이 IE과 관련이있다, 내가하는 똑같은 일이지만 파이어 폭스에서 제대로 작동합니다. AFAIK가 위치를 저장하고 당신처럼 scrollTop을 사용하면 IE를위한 유일한 workarround 일 수 있습니다.