Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onItem will be called twice when triggers a submenu item #83

Open
XiaoMouR opened this issue May 3, 2015 · 2 comments
Open

onItem will be called twice when triggers a submenu item #83

XiaoMouR opened this issue May 3, 2015 · 2 comments

Comments

@XiaoMouR
Copy link

XiaoMouR commented May 3, 2015

I create a menu which has a submenu with two items.When I trigger one of items in submenus,the onItem in the option of contextmenu will be called twice.
Follow is my code.

<!-- menu -->
<div id="context-menu">
      <ul class="dropdown-menu multi-level" role="menu">
        <li class="dropdown-submenu">
          <a href="javascript:;">item</a>
          <ul class="dropdown-menu">
            <li><a href="javascript:;">subitem1</a></li>
            <li><a href="javascript:;">subitem2</a></li>
          </ul>
        </li>
    </ul>
</div>
//option
  var ipsession_contextmenu = {
    target:"#context-menu",
    before: function(e,context){
    },
    onItem: function(context,e){
           alert($(e.target).text());
    }
  };

By the way,if I add "this.closemenu()" to the end of onItem,it will stop the second time calls.

@oddui
Copy link

oddui commented Jun 21, 2015

I put e.stopPropagation() in onItem. It stops onItem being called multiple times. Not sure whether it breaks anything.

@gjohncock
Copy link

ive been playing around with this and cannot get it to termininate gracefully. if I just use the closemenu command it throws an error saying "e" is not valid.
The reason it is happening on sub items is that its propogating up the menu tree and fires for all the parent li tags.
would be good if there was a way to tag an item as a parent as usually you dont want anything to happen when you click this item, its sole purpose is to display the submenu where all the active items are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants