metismenu: toggle doesn't work when no sub-menu is present

Hi, I found out that toggle doesn’t work right with items that don’t have sub-menus.

For example:

<ul id="menu">
    <li><a href="#/page1">Page 1</a>
        <ul>
            <li><a href="#/sub-page1">Sub-page </a></li>
            <li><a href="#/sub-page2">Sub-page 2</a></li>
        </ul>
    </li>
    <li><a href="#/page2">Page 2</a></li>
</ul>

The problem is line 37 in the code:

$this.find("li").has("ul").children("a").on("click" + "." + pluginName, function(e) ...

Everything works fine when I remove .has("ul") from the code.

The thing is I’m working with angular and not using direct links but routing based on my location, so even when the link doesn’t have a sub-menu, it still doesn’t go to a new page but should toggle the other menus.

Cheers, Jan Fucik

About this issue

  • Original URL
  • State: open
  • Created 10 years ago
  • Reactions: 1
  • Comments: 20 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Please fix this! The fix from slimsoft from over a year ago works, why hasn’t it been integrated? I don’t want to edit a node module!

Hi! Hava the problem solved in this branch: https://github.com/pereiradiogo/metismenu/tree/fix_parent_menus

@onokumus Check de PR