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: showOnClick doesn't hide submenu when clicked again

Home Forums Latest release 1.1.x showOnClick doesn't hide submenu when clicked again Reply To: showOnClick doesn't hide submenu when clicked again

#8326
admin
Keymaster

Hi, actually you are not missing anything. It’s currently really working like that by default. I will most probably change this in the next release. In the meantime, you could use the following tweak via the API to achieve what you need:

// SmartMenus jQuery - a second click on a main menu item when "showOnClick: true" should hide the sub menu
$('#main-menu').on('click.smapi', function(e, item) {
	if (e.namespace == 'smapi') {
		var obj = $(this).data('smartmenus');
		if (!obj.isCollapsible() && obj.opts.showOnClick) {
			var $sub = $(item).dataSM('sub'),
				firstLevelSub = $sub ? $sub.dataSM('level') == 2 : false;
			if (firstLevelSub && $sub.is(':visible')) {
				obj.menuHide($sub);
				obj.clickActivated = false;
				return false;
			}
		}
	}
});

Cheers!

Edit: Just add this code after your SmartMenus init code.