jquery-contextMenu icon indicating copy to clipboard operation
jquery-contextMenu copied to clipboard

jQuery.browser removed in 1.9

Open Kipperlenny opened this issue 13 years ago • 2 comments

http://api.jquery.com/jQuery.browser/ was removed (and depr. since 1.3)

Your code now fails here:

if ($.browser.msie && options.leftClick) {
  mouseEvent = 'click';
} else if ($.browser.msie && !options.leftClick) {
  mouseEvent = 'contextmenu';
}

Kipperlenny avatar Jan 27 '13 11:01 Kipperlenny

You can get around this by using https://github.com/jquery/jquery-migrate/ for the moment. Hopefully this code will be updated to stop relying on $.browser.

emmaly avatar Apr 11 '13 04:04 emmaly

My understanding is that the need for browser here is because IE doesn't provide the same values for the button attribute of a mouse event as "standards compliant" browsers, and we want to determine which button was clicked. Some testing with IE 8 (the only IE I have handy for testing) and a recent FireFox shows the issue to be worse, in that button, which, and buttons are all unreliable on 'click' and 'contextmenu' events, even in FireFox. They're reasonably well documented for 'mousedown', and IE8 behaves as expected here, but at that time you don't know if there will be a 'click' versus a drag, for example. An alternative approach takes advantage of the fact (tell me if this isn't universal) that the 'click' event isn't generated for right clicks, and the 'contextmenu' event isn't generated for other, including left, clicks. So create two separate handlers, one for the "correct" button (pretty much the existing handler with the determination of correct versus incorrect button removed), and one for the "wrong" button (just calls hideMenu()). Then bind one to 'click' and one to 'contextmenu', using options.leftClick to decide which event gets which handler. While I haven't exhaustively tested it, I have an example of the above that works for me. If requested by arnklint I can either send him a copy or go through the fork, modify, pull-request route.

ke1g avatar May 07 '13 13:05 ke1g