www.webdeveloper.com
Results 1 to 4 of 4

Thread: delaying

  1. #1
    Join Date
    Apr 2012
    Posts
    99

    delaying

    Hello everyone:

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

    Code:
    $("#refresh").replaceWith(divClone).delay(8000);
    What happens is it acts like the delay function is not even there.

  2. #2
    Join Date
    Dec 2012
    Posts
    96
    Try wrapping it in a timeout?

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

  3. #3
    Join Date
    Apr 2012
    Posts
    99
    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?

    Code:
    $("#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);
    	});
    	
    });

  4. #4
    Join Date
    Mar 2009
    Location
    Wherever i lay my hat
    Posts
    180
    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:

    $("#mainContent").load("functions.php?cmd=2");
    $('#loadingMain').toggle();

    You send a request to the server and immediately toggle that element. It usually takes some time for the request to return, so you should do that as a callback:

    $("#mainContent").load("functions.php?cmd=2", function() {
    $('#loadingMain').toggle();
    } );

    and maybe even the slideDown function, but i am not really sure, what you want

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles