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.

Re: Prevent menu from expanding on hover?

Home Forums Older releases 0.9.x Prevent menu from expanding on hover? Re: Prevent menu from expanding on hover?

#1672
admin
Keymaster

Hi again and sorry for the delay! Unfortunately, I wasn’t able to look into this earlier.

You can achieve the exact Bootstrap behavior, for example, like this – first grab a fresh copy of “jquery.smartmenus.bootstrap.js” and then:

1) Activate touch mode even when a mouse is present by adding the following at the end of the file to overwrite the default prototype method:

// activate touch mode permanently
$.SmartMenus.prototype.isTouchMode = function() {
	return true;
};

This will make sure items are only activated on click/tap.

2) Change the following:

'click.smapi': function(e, item) {
	var obj = $(this).data('smartmenus');
	if (obj.isCollapsible()) {
		var $item = $(item),
			$sub = $item.parent().dataSM('sub');
		if ($sub && $sub.dataSM('shown-before') && $sub.is(':visible')) {
			obj.itemActivate($item);
			obj.menuHide($sub);
			return false;
		}
	}
}

like this:

'click.smapi': function(e, item) {
	var obj = $(this).data('smartmenus'),
		$item = $(item),
		$sub = $item.parent().dataSM('sub');
	if ($sub && $sub.dataSM('shown-before') && $sub.is(':visible')) {
		obj.itemActivate($item);
		obj.menuHide($sub);
		return false;
	}
}

This will make sure parent items onclick always just toggle their sub menus even on desktop (you cannot activate their links like with Bootstrap’s default navbars).

Please let me know if you this does the trick for you.