can't `destroy` context menu
Hi and thanks for jquery-contextMenu,
From 2.2.4 I can't destroy a context menu created with $('ul').contextMenu({selector: 'li'}); using contextMenu('destroy')
This seems to be caused by the fix e738733d7b7f7a630c608799ee86b4c35da8ab92 to issue #397. Indeed, the selector is used to select children elements of the context. So $(context).is(o.selector) is always false, and the menu is never destroyed.
Hmm, when I run against master it I can destroy a contextmenu fine. Can you also reproduce this on the documentation site?
I should have been more precise in my description. I was referring to $('ul').contextMenu('destroy'), that does not destroy the menu.
STR:
- go to https://swisnl.github.io/jQuery-contextMenu/demo/on-dom-element.html
- open the console and type
$('#the-node').contextMenu('destroy')
Expected:
- the context menu associated to
#the-nodeshould be destroyed (and was destroyed before v.2.2.4)
Happens:
- the context menu is not destroyed
If you put a breakpoint on line 1597 of jquery.contextMenu.js, you'll see that the code can never go further than line 1598, as context is $('#the-node') and cannot match a selector which is intended to find children elements.
I think I have the same problem as described above.
Then I tried:
$.contextMenu({ selector: 'sel', ... })
...
$.contextMenu('destroy', 'sel');
Seems to work, but after some menu creation and deletion chrome crashes with stack overflow, but don't know why (in the moment).
Hmm, i made a PR to fix this, but this breaks $.contextMenu('destroy', 'selector'); unfortunately. I need to try again later.
The problem is that it is possible to destroy either from a context (like $('.menu')) and without a context, which means it will use document as the context. This is fixable, just not for me, friday at the end of the day :)
Then I tried:
$.contextMenu({' selector: 'sel', ... }) ... $.contextMenu('destroy', 'sel');Seems to work, but after some menu creation and deletion chrome crashes with stack overflow, but don't know why (in the moment).
This worked for me. v2.6.4
$('wrapper').contextMenu({
selector: 'input'
...
});
$('wrapper').contextMenu('destroy');
and I changed it to
$('wrapper').contextMenu({
selector: 'input'
...
});
$.contextMenu('destroy', $('wrapper'));
This issue has been present for a long time and still persists. I have created an example that reproduces the issue: https://codepen.io/y1j2x34/pen/zYeLqYQ. When I click the "Remove box 1" button, the .context-menu-list node is not being deleted.