SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery firing multiple events

    Hi.

    Below is some code that I am working on which upon a sucessful result displays a lightbox. The problem I am having is that bit code that fires the light box seems to trigger multiple times causing everything to flicker etc while it sorts itself out.

    Looking in Firebug I can see that the lightbox was fired at least 40 times.

    The only thing I think it might be is the time out function however I am not sure how to fix this at all.

    Sorry for the lay out of the js as well, it not easy to format!!

    Cheers Chris

    Code JavaScript:
    function bookWebinar(webinarId,tafUrl)
      {
         $.post("my_content/gtw/webinarProcess.php", {wid: webinarId,bookWebinar:1}, 
            function(data)
    	{
    	    var obj = jQuery.parseJSON(data);
    	    if(obj.result=="failure")
    	            {
    		//show the message in the div with a red background
    		$(".bookingResult").addClass("classroomExpertError");
    		$(".bookingResult").html(obj.Message);
            		$('.bookingResult').show('slow', function()
    			{
    			    setTimeout(function(){$('.bookingResult').hide('slow');},3000);
    			});
    	          } 
    	else
    	         {
    		//show the message in the div with a green background
    		$(".bookingResult").addClass("classroomExpertSuccess");
    		$(".bookingResult").html(obj.Message);
            		$('.bookingResult').show('slow', function()
    		          {
    			 setTimeout(
    			function(){
    			$('.bookingResult').hide('slow', 
    			       function() 
    				{
    				//need to put the taf form in here
    				$.colorbox({href:"my_content/taf.php?tafUrl="+tafUrl,
    				onClosed: function (message) { 
                				window.location.replace("my_content/opening-offer.php"); 
            				}
    	                                          });
    				});},3000);
    				});
    				}
     
    			}); 
            return false; 
     
    	}

  2. #2
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi.

    Is anyone able to offer any suggestions?

    Thanks
    Chris


Bookmarks

Posting Permissions

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