onokumus / metismenu

A collapsible jQuery menu plugin

Home Page:https://onokumus.github.io/metismenu/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hover example: close submenus when user clicks on the page

ivansammartino opened this issue · comments

commented

Version

version: 2.7.0

Description

I noticed that clicking on main menu items in the "hover" example keeps the menu opened even if I go around the page: this is very fine, but when the user clicks on the page body I'd expect the submenus to close... how can I achieve this?

Thank you :-)

Hello, you need to use jquery event propagation method.

$(document).ready(function()
{
$("body").mouseup(function(e)
{
var subject = $("#yourMetisMenuUl");

    if(e.target.id != subject.attr('id') && !subject.has(e.target).length)
    {
        subject.hide();
    }
});

});