swisnl / jQuery-contextMenu

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

Ajax submenu inconsistent display #706

Closed thebordella closed 4 years ago

thebordella commented 4 years ago

Great plugin! I am just having trouble with one thing.

My context menu has a submenu whose items load via ajax using promises. I followed the promises example here: https://swisnl.github.io/jQuery-contextMenu/demo/async-promise.html#example-html

The code does work - but the submenu does not always appear after the promise is resolved. The weird thing is, sometimes the submenu does appear. Even if I reload the same page repeatedly, with the exact same ajax call being used each time. On some page loads, the submenu appears just fine. On some page loads, the submenu does not pop open. It seems very random. Nothing is changing between page reloads.

When I inspect the page with browser developer tool, I can see that the submenu is populated with the ajax data always, on every page load. So the ajax is working fine, every time. The promise is always being returned with correct data. Problem is, somehow contextMenu does not always "show" the submenu after the promise is resolved. Sometimes it does. Very confusing!

I am using v2.9. Same problem with v2.8. Any ideas? Thank you!

bbrala commented 4 years ago

Hmm, that is weird, do you have this problem also on the demo page or only in your own code? Also; what browser are you using, and what version of the menu and jQuery.

thebordella commented 4 years ago

Upon further investigation, this problem is not related to promises or ajax or dynamically populated the submenu. For some reason, the submenu does not always appear when I hover over the parent item - even in a very simple context menu with static items. I will investigate further.