0

I have a short question for you. Could anybody help me figure out why after an Ajax request, the page scroll is changing back to the top? I think it's about JQuery. I can't find too much info on the web, so I ask for your help. This is the test page where I'm doing that. Try changing and see what is happening. Thank you so much!

www.*.ca/test/script.php

Got the answear. Thank's

Gigg
  • 1,019
  • 3
  • 11
  • 20

2 Answers2

2

I just ran into this situation with some embedded pagination and I came up with a trick for dealing with it. On page load I grab the calculated pixel height of the content div and then set that fixed height back onto itself. This keeps the div at a fixed size while the page contents are destroyed and replaced.

var height=$('#content').height();
$('#content').height(height);

Or more briefly:

$('#content').height($('#content').height());
1

Because the page momentarily becomes shorter, so the scrolling position cannot remain where it was or else the page would be scrolled past its contents.

Bemmu
  • 17,849
  • 16
  • 76
  • 93
  • i see . . . So what should I do? Make a div with a bigger height that will get the table into it? So when the request is made the div height remains the same? – Gigg Jun 14 '11 at 07:31
  • and could you also tell me how to set the width so it won't chage with each refresh? It becames frustrating when the table cell's width changes so often. Thank's again – Gigg Jun 14 '11 at 07:40