Opening a second menu can break the "layer".
lmonilsson opened this issue · 13 comments
I am testing the demo at http://medialize.github.com/jQuery-contextMenu/demo/on-dom-element.html, and have encountered an issue.
- Right-click on one of the items.
- Right-click on a different item.
The first menu closes, and the second menu pops up, but only for a moment. After that, nothing on the page can be clicked. When clicking anywhere at this stage, the error log in Firefox says:
Error: TypeError: root.$layer is undefined Source File: http://medialize.github.com/jQuery-contextMenu/src/jquery.contextMenu.js Line: 362
thank you for reporting that - it's fixed…
Hi,
i download the latest and still its giving me error.
TypeError: root.$layer is undefined
root.$layer.hide();
I am not getting that error anymore. What browser are you using? http://medialize.github.com/jQuery-contextMenu/demo/on-dom-element.html works for me…
Hi please look at this script i just create for you.
load the page by clicking left side links more than 2-3 times.
http://hddezign.com/contextMenu/
$ curl 'http://hddezign.com/contextMenu/' --connect-timeout 3
curl: (6) name lookup timed out
can't open that link…
http://hddezign.com/contextMenu/
open it in browser. then load different plans 3-5 times and move your mouse over days and you will see the error.
you can download the code here:
http://orientbsol.com/Hostings/contextMenu.zip
You should seriously reconsider your approach… Don't have your POST
request return a <script>
that never changes… Apply that once, in the main document. Use delegated events. instead of $('#add-plan-trigger-days').on('click', function(e) {
do $(document).on('click', '#add-plan-trigger-days', function(e) {
and the event handler will still apply even after your content was switched after that ajax request. contextMenu already uses delegated events, so you do not need to re-initialize it every time.
(I applied that change to your code and it worked for me)
But you did find a bug: #110
I can reliably reproduce the issue on this very page: http://medialize.github.com/jQuery-contextMenu/demo/on-dom-element.html by right-clicking rapidly (or not so rapidly on slower machine/when the CPU usage is high) multiple times.
I would suggest adding checks to ensure that the $layer is defined before calling the hide().
Issue can be reproduced, like robertoea wrote.
It is easy to reproduce by making circles when right clicking fast.
The problem lies in:
[...]
// find the element that would've been clicked, wasn't the layer in the way
if (document.elementFromPoint) {
root.$layer.hide(); // <-- here, line 367
[...]
Could You verify it, please?
Can anyone help with this bug. I get the same error if I click out of term.
also I keep seeing this
TypeError: Argument 1 of Document.elementFromPoint is not a finite floating-point value.
Was able to reproduce this as well. For the 'finite' error, something like this helps: https://gist.github.com/Lajnold/5404556
Of course, the $root.layer problem is on that path and will still occur.
I'll try and create a patch for this, which may involve having to read the source code.