Start a new discussion

To start a new discussion please visit the discussions section of the GitHub home page of the project.

Discussions on GitHub

You can also search our old self-hosted forums for any useful information below but please note that posting new content here is not possible any more.

Reply To: Hide submenu of clicked menu item only

Home Forums Older releases 1.0.x Hide submenu of clicked menu item only Reply To: Hide submenu of clicked menu item only

#3090
admin
Keymaster

There you go:

// deactivate item's sub on Space if it's activated
$.SmartMenus.prototype.old_rootKeyDown = $.SmartMenus.prototype.rootKeyDown;
$.SmartMenus.prototype.rootKeyDown = function(e) {
	if (!this.handleEvents()) {
		return;
	}
	if (this.isCollapsible()) {
		if (e.keyCode == 32) {
			var $target = $(e.target);
			if ($target.is('a') && this.handleItemEvents($target)) {
				var $sub = $target.dataSM('sub');
				if ($sub && $sub.is(':visible')) {
					this.menuHide($sub);
					e.preventDefault();
					return;
				}
			}
		}
	}
	this.old_rootKeyDown(e);
};

This replaces the default rootKeyDown method so just include it on your page after the script core “jquery.smartmenus.js”.