delaying

droidus

I am trying to delay some content being replaced. here is my code snippet:

$("#refresh").replaceWith(divClone).delay(8000);

What happens is it acts like the delay function is not even there.

iBeZi

Try wrapping it in a timeout?

setTimeout(function() {
$("#refresh").replaceWith(divClone);
},8000);

droidus

i'm having another odd issue, slightly related to timing. i would like the page to, at the end, load the new contents to the main container, then show the new page. instead, it shows the old page with the old content, then changes after that. is there any way to change this so that it is changed before it is actually shown?

$("#genInfo").click(function() {
$('#mainContent').slideUp(1000, function() {
// get the height of the main content so it can be put back properly
//$('#mainContent').height();
//show loading content
$('#loadingMain').toggle();
setTimeout(function() {
},2000);
setTimeout(function() {
// clone the div so the user can go back to the original content
var divClone = $("#mainContent").clone();
// then process the request... we will hide content until it is ready
$("#mainContent").load("functions.php?cmd=2");
// now show the content
$('#loadingMain').toggle();
$('#mainContent').slideDown(1000);
},10000);
});
});

haulin

Can you post your whole page or at least some of the html needed for this JS snippet to work? It's hard to imagine what you want and where the bug is just from this. I only see one empty timeout, but that can't be the problem, because the callback function does nothing:

setTimeout(function() {
},2000);

If you really see the old content just for a moment, then the problem is probably here: