1

I am using the jquery.address plugin to dynamically load my #content using Ajax. I also am using some effects for loading the new #content (i.e the old #content flies out, the new comes in from top, or from the side etc.) but I think that's not the problem..

Problem is, that after the ajax request, the scroll position does not remain and the page jumps back to the top.

Is there any plugin/soultion on that? I read that storing the current position in a cookie and using $("html,body").animate({ scrollTop: x }, t); would help. But isn't there a better maybe more simpler way to accomplish that?

Thanks beforehand!

Mike

EDIT

Solved: Found out the solution is (comment out .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');
     }
 }); 
Matt
  • 22,721
  • 17
  • 71
  • 112
Mike
  • 2,686
  • 7
  • 44
  • 61
  • found this http://stackoverflow.com/questions/4284596/jquery-address-page-jump-issue-in-scrolling-scenarios-address-wrap but return false; doesn't work for me. Is this to be accomplished with address.wrap()? – Mike Aug 28 '11 at 17:20

1 Answers1

0

This has to do with IE, mine does the same thing but works correctly in firefox. AFAIK saving the position and using scrollTop like you did, could be the only workarround for IE.