i am updating content with ajax call from server.
after the update, i empty the wrapper div, that contains the data, and fill it again with the new data.
so far so good.
the problem is – that on a
$('#MessagesContainer').empty();
method – the scrollbar changes back up.
so if someione want to add data and he is in the bottom of the page, the scroll goes back up.
this action makes sense, but for this particular action i want to avoid it since it’s not so “user-friendly”.
well, thanks for your answers.
use .html() would probably be better than .empty() and re-append the data.
but, the thing is that for my implementation that is not possible.
so what i did is implemented
that remove all the elements after index ‘x’ in the collection and then append data from this ‘x’ index. that did the trick. the scrollbar stays where it is. it’s not 100% percent user-friendly since it make some of the data disappear for a milisecond and then it comes back, but at this currently point, it’s the best i could think of.