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.

Register

You will be emailed a link to set your password.

Login

Lost password?