If a menu is set to open on click only, then a click anywhere outside the open menu should close it. The same behavior as an OS menu.
This is the jQuery I'm using, for the "no-style" version:
(function ($) {
Drupal.behaviors.omMaximenuClose = {
attach: function (context, settings) {
$('html').click(function() {
// Close any open menus.
$('.om-maximenu-content:visible').each(function() {
$(this).hide();
});
});
// Allow opening closed menu.
$('.om-link').click(function(ev) {
ev.stopPropagation();
});
// Don't close an open menu if the click is inside it.
$('.om-maximenu-content').click(function(ev) {
ev.stopPropagation();
});
}
}
})(jQuery);
Comments
Comment #1
danielhonrade commentedcommit in dev, with some modifications...
Comment #2
johnpitcairn commentedLatest dev is not quite right. A click anywhere inside the dropdown content will close it. I still need to add this to the behaviour attach function:
Comment #3
danielhonrade commentedThanks John for looking into this, committed on dev.