Reply To: Automatically close sub menus when opening other sub menus

Home Forums Older releases 1.0.x Automatically close sub menus when opening other sub menus Reply To: Automatically close sub menus when opening other sub menus

#2769
katieTBA
Participant

Great, thanks! Here is the script as I now have it in the <head>:

<script type="text/javascript">
	$(function() {
			   
			   $('#main-menu').bind('click.smapi', function(e, item) {
		var obj = $(this).data('smartmenus');
		if (obj.isCollapsible()) {
			var $item = $(item),
				$sub = $item.dataSM('sub');
			if ($sub && !$sub.is(':visible')) {
				obj.itemActivate($item, true);
				return false;
			}
		}
	});
		$('#main-menu').smartmenus({
		});
		$('#menu-button').click(function() {
    var $this = $(this),
        $menu = $('#main-menu');
    if ($menu.is(':animated')) {
      return false;
    }
    if (!$this.hasClass('collapsed')) {
      $menu.slideUp(250, function() { $(this).addClass('collapsed').css('display', ''); });
      $this.addClass('collapsed');
    } else {
      $menu.slideDown(250, function() { $(this).removeClass('collapsed'); });
      $this.removeClass('collapsed');
    }
    return false;
  });
	});
</script>

That works! Just wanted to double-check: I’m not unnecessarily duplicating anything, am I?

Thanks again!

Register

You will be emailed a link to set your password.

Login

Lost password?