I have returned with yet another question. If I want to collapse all the other menu items before expanding the clicked one I tried using this: ... .bind('showme', function() { $("a.Category").trigger("showme"); $(this).data("hidden", false).parent("li") .css({background: "#00ff00"}).children("ul").show(); return false; }) ...
This works for the one-level menus but causes problems with multi- level menus. Because when I click a child menu item the parent of that item i triggered to be hidden. Can anyone help me with this problem? On Oct 13, 11:15 pm, Dave Methvin <[EMAIL PROTECTED]> wrote: > How about this? It creates a couple of custom events (showme and > hideme) that you trigger to set the state, and the click event just > delegates to the right one based on the current state. I just > triggered a click on CollapseAll to set the initial state; if you > didn't want the coloring to be there you could add some code to remove > it at the bottom. > > $(document).ready(function() { > $("a.Category") > .bind('showme', function() { > $(this).data("hidden", false).parent("li") > .css({background: > "#00ff00"}).children("ul").show(); > return false; > }) > .bind('hideme', function() { > $(this).data("hidden", true).parent("li") > .css({background: > "#ff0000"}).children("ul").hide(); > return false; > }) > .bind('click', function() { > $(this).trigger($(this).data("hidden")? "showme" : > "hideme"); > return false; > }); > $("#ExpandAll").bind('click', function() { > $("a.Category").trigger("showme"); > return false; > }); > $("#CollapseAll").bind('click', function() { > $("a.Category").trigger("hideme"); > return false; > }).trigger("click"); > > });