Need help with easy question - init js

Discussion in 'JavaScript' started by Sn@Ke, Jul 9, 2009.

  1. #1
    Ok, so I suck at anything Java

    Heres my problem, I have lightbox.js and a java drop down menu on my site, and when I have the Lightbox in the header and then the Menu, only the menu loads and lightbox fails. When I have them the other way around I get the lightbox working and the menu fails

    <script src="<?php echo $domain; ?>js/prototype.js" type="text/javascript"></script>
    	<script src="<?php echo $domain; ?>js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
    	<script src="<?php echo $domain; ?>js/lightbox.js" type="text/javascript"></script>	
    	
    	<script type="text/javascript" src="<?php echo $domain; ?>script.js"></script>
    
    	<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    
    	
    	<script type="text/javascript">
    $(document).ready(function(){
    
    	
    	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
    	
    	$("ul.topnav li span").click(function() { //When trigger is clicked...
    		
    		//Following events are applied to the subnav itself (moving subnav up and down)
    		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
    
    		$(this).parent().hover(function() {
    		}, function(){	
    			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
    		});
    
    		//Following events are applied to the trigger (Hover events for the trigger)
    		}).hover(function() { 
    			$(this).addClass("subhover"); //On hover over, add class "subhover"
    		}, function(){	//On Hover Out
    			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
    			
    			
    	});
    
    });
    </script>
    
    
    
    </head>
    Code (markup):
    With the above code the Menu loads fine but the lightbox wont init.

    I've tried adding <body onload="init();initLightbox()">

    But it still doesn't work, unless the lightbox comes after the menu in the header.

    So I figure i need to somewho init the lightbox in the menu code?

    I don't know... I think its simple answer but i suck
     
    Sn@Ke, Jul 9, 2009 IP
  2. JavaScriptBank.com

    JavaScriptBank.com Peon

    Messages:
    141
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    JavaScriptBank.com, Jul 10, 2009 IP