Jump to content

Need Help with Nav. drop down


vincej

Recommended Posts

Hi- I'm totally new to Jquery /Javascript although quite competent with CodeIgniter / PHP. I built a menu with PHP / Mysql.  I found some Jquery code out of a SitePoint Book on Jquery ( Novice > Ninja ).

 

In putting the two pieces together it almost works.  It slides open and closed. I can navigate on the submenus to the correct destination, but for some curious reason the top Category level will not open the page, even though, I can see when hovering over the Category link that the correct url is being presented.

 

I can't see why this should be - I provide the Jquery and PHP below.

 

Many Many thanks For Any Help You Can Offer !

 

 

<script>

$(document).ready(function(){
$( '#menu > li > ul' )
.hide()
.click(function( e ){
	e.stopPropagation();
});
  $('#menu > li').toggle(function(){
  $(this)
      .removeClass('waiting')
      .css('background-position', 'right -20px')
      .find('ul').slideDown();
  }, function(){
  	$( this )
      .removeClass('waiting')
      .css('background-position', 'right top')
      .find('ul').slideUp();
  });
  
  $('#menu > li').hover(function() {
    $(this).addClass('waiting');
    setTimeout(function() {
      $('#menu .waiting')
        .click()
        .removeClass('waiting');
    }, 400);
  }, function() {
    $('#menu .waiting').removeClass('waiting');
  });
});

</script>


<?php

if (count($navlist)){

  echo "<ul id ='menu'>";
  foreach ($navlist as $key => $list){
  	foreach ($list as $topkey => $toplist){
    	echo "<li>"; //class='cat'
    	echo anchor("welcome/cat/$topkey",$toplist['name']);
    	
    	if (count($toplist['children'])){
    		foreach ($toplist['children'] as $subkey => $subname){
    			echo "<ul>"; // class='subcat'
    			echo anchor("welcome/cat/$subkey",$subname);	
    			echo "</ul>";
    		
		}
    echo "</li>";}
}
  }
  echo "</ul>";
}



Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.