sydcanem / bootstrap-contextmenu

Context menu plugin for Twitter's Bootstrap framework
http://sydcanem.com/bootstrap-contextmenu/
645 stars 193 forks source link

menu should close if right click again somewhere else #72

Closed yeban closed 9 years ago

yeban commented 9 years ago

Right click to open bootstrap contextmenu. Then right click somewhere else to open browser's default contextmenu.

Here's what we get: screen shot 2014-11-25 at 3 06 00 pm

Expected: only browsers right click menu should be visible

yeban commented 9 years ago

Also, escape to dismiss the menu doesn't work after this.

sydcanem commented 9 years ago

This is fixed by 04d42fb. Please update to the 0.3.1.

yeban commented 9 years ago

I'm sorry, the fix doesn't seem to work.

Also, package.json still states version number to be 0.3.0 which I think is why bower says:

bower bootstrap-contextmenu#0.3.1         mismatch Version declared in the json (0.3.0) is different than the resolved one (0.3.1
sydcanem commented 9 years ago

"I'm sorry, the fix doesn't seem to work."

Have you added data-toggle="context" to your context elements? (not the menu). Already fixed the versioning.

yeban commented 9 years ago

No, I activate contextmenu using JS (and not data- attributes)

$('.context').contextmenu({
  target:'#context-menu'
});

I'm adding editing layer over an existing genome visualisation software. My options are a bit limited here. It would be great if you can fix this for JS only activation too.

yeban commented 9 years ago

Ok. Using data- attrs works for me. But don't you think this should work even without adding data-toggle="context" to the context elements?

sydcanem commented 9 years ago

That's actually used for plugin clean-up. Some bootstrap 3 JS plugins now requires you to add data-* attributes probably for the same reason.

yeban commented 9 years ago

Ok, I didn't know. In any case, it works for me now. So I'm fine to close this issue.

rgriffith commented 9 years ago

I am experiencing this same issue with v0.3.2. I tried adding data-toggle="context" to my elements, but that does not work. Here is how I am using the plugin:

$('#page-container').contextmenu({
    target: '#context-menu',
    scopes: '.context',
    before: function(e, ctx) {
      console.log("Menu is about to open.");
      return true;
    }
  });

Any suggestions would be greatly appreciated. Thanks!

yeban commented 9 years ago

I can only ask you to make sure that data-toggle-"context" is applied to #page-container element. I'm also wondering, from the name of it, how big is this 'page-container' are subsequent right clicks being triggered outside the container?

rgriffith commented 9 years ago

The #page-container element is the outermost container on my page and spans the entire width and height. Adding data-toggle="context" to #page-container will work since it essentially replaces all context menus; however, it does not produce the desired effect. What I would like to do is only replace the context menu for specific links within my page (.cs-context and .link-with-context), leaving the default browser context menu everywhere else.