Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Posts
    190
    Thanks
    25
    Thanked 0 Times in 0 Posts

    on submit, show Fancybox after 5 seconds

    Hi again

    This probably is easy but I cant see where im going wrong.

    So what is supposed to happen is that onsubmit there is a 5 second wait before the fancybox function opens. The problem I have is when I try to add the setTimeout function and I bet its something easy but I cant get it to work.

    Code im using is below. Anybody help me out please?

    Thanks!

    Code:
    $(document).ready(function(){
    //---
    $("form").submit(function(e){
    
    	setTimeout(function (){
    
    		$.fancybox({
    		 'href' : '#loading-wait',   
    		 'width' : 650,
    		 'height' : 350,
    		 'autoScale' : false,
    		 'transitionIn' : 'none',
    		 'transitionOut' : 'none',
    		 'scrolling' : 'no',		 
    		 'type' : 'inline',
    		 'showCloseButton' : false,
    		 'hideOnOverlayClick' : false,
    		 'hideOnContentClick' : false    
    		 })
    		 
                     return false;
    	})
    	
            , 5000 );
    
    });
    
    });

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,391
    Thanks
    11
    Thanked 568 Times in 561 Posts
    Move the "return false" from inside the setTimeout to the last line of the submit event handler. Additionally, there is one additional closing bracket that needs to be removed
    Code:
    $("form").submit(function(e){
    
    	setTimeout(function (){
    
    		$.fancybox({
    		 'href' : '#loading-wait',   
    		 'width' : 650,
    		 'height' : 350,
    		 'autoScale' : false,
    		 'transitionIn' : 'none',
    		 'transitionOut' : 'none',
    		 'scrolling' : 'no',		 
    		 'type' : 'inline',
    		 'showCloseButton' : false,
    		 'hideOnOverlayClick' : false,
    		 'hideOnContentClick' : false    
    		 })
    		 
            }, 5000 );
    
            return false;
    
    });
    Last edited by devnull69; 10-17-2012 at 07:08 AM.

  • Users who have thanked devnull69 for this post:

    vorl (10-20-2012)

  • #3
    Regular Coder
    Join Date
    Feb 2005
    Posts
    190
    Thanks
    25
    Thanked 0 Times in 0 Posts
    Thank you so much!


  •  

    Posting Permissions

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