swisnl / jQuery-contextMenu

jQuery contextMenu plugin & polyfill
https://swisnl.github.io/jQuery-contextMenu/
MIT License
2.25k stars 744 forks source link

Not show menu when is right click on items that appears above container contextmenu. #736

Closed cplaiu closed 3 years ago

cplaiu commented 3 years ago

I am creating a context menu container where user right click and can add folders. All this folders appears above this container and I'm trying to prevent display contextmenu on it.

I have tried to prevent diplay menu using this code:

$(document).on("contextmenu", ".folder-box", function(e){
  e.preventDefault();
  $('.context-block').contextMenu(false);
});

$(document).on("contextmenu", ".context-block", function(e){
  e.preventDefault();
  $('.context-block').contextMenu(true);
});

but the context menu is still showing when right clicking.

CodePen Example

cplaiu commented 3 years ago

changing e.preventDefault(); is return false; working