Stopping jQuery Jumping to Newly Loaded Content.

Posted by Damien on Stack Overflow See other posts from Stack Overflow or by Damien
Published on 2009-10-22T10:06:02Z Indexed on 2010/05/10 9:54 UTC
Read the original article Hit count: 193

Filed under:
|
|

I have a div with is replaced upon certain user actions. These actions are performed under the div that is being replaced and in the case that the div is too large to fit completely into the view window, along with the buttons used to change it underneath, the browser will jump to the top of the newly loaded div. Which is annoying.

Does anyone know of a way to stop these? Cheers.

Here is the jQuery code. ChartContent is a small blob of html

function UpdateChartImage(ChartContent) {
//do updates on div here 
    var existingChart = $("#" + $(ChartContent).attr("id"));
    existingChart.fadeOut("fast", function() { existingChart.replaceWith(ChartContent); }).fadeIn("fast");
}

Incidentally I have prevented the button from doing it's default behaviour so I don't think it's related to that.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about div