javascript - Wanting to keep scroll position when refreshing a partial page template through Rails and AJAX -
i'm using long polling. every time use ajax refresh page partial inside div scroll bar, contents scrolled top automatically. there way load partial , keep scroll position?
<div style="height:600px; overflow-y:scroll;"> <!-- partial loads here , greater 600px, , can different height each time. --> </div>
you can store scroll position before ajax request, , set after completed:
var scrollposition = $(window).scrolltop(); // ajax polling code, on success code below. $(window).scrolltop(scrollposition);
Comments
Post a Comment