CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   jQuery on submit, show Fancybox after 5 seconds (http://www.codingforums.com/showthread.php?t=277301)

vorl 10-17-2012 01:21 AM

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. :confused:

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 );

});

});


devnull69 10-17-2012 07:06 AM

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;

});


vorl 10-20-2012 01:31 PM

Thank you so much! :D


All times are GMT +1. The time now is 03:20 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.