swisnl / jQuery-contextMenu

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

Event handler problem with IE8 #106

Closed KernelLeak closed 8 years ago

KernelLeak commented 11 years ago

We're currently developing a small internal app that has to run on Firefox and IE8 using jQuery, KnockoutJS, jQuery DataTables and your context menu plugin.

We've found that using the context menu to open a jQuery dialog with a DataTable in it that's filled via AJAX sometimes causes an error in some of the event handlers because some of the objects that the event handler assumes exist have already been destroyed. After this happens the context menu doesn't go away, and hovering the mouse over it just causes another JavaScript error...

(For instance, the blurItem handler fires and all of a sudden data.contextMenu was null and thus setting "opt.$selected" a few lines down causes the error)

I've liberally sprinkled checks whether root and opt are defined across the event handlers and if not simply exit them, and that has fixed the problem.

KernelLeak commented 11 years ago

I've attached the patch at https://gist.github.com/4619523

rodneyrehm commented 11 years ago

thank you! Can you

a) do you have a minimal test-case (jsfiddle.com, jsbin.com) so I can have a look at an alternate solution? b) fork the repo, make your changes and send a pull request? (please consider code-style, namely braces for one-line-if)