I want to show a jQuery-UI dialog box as a popup when user clicks on left mouse button or the middle one. It works for left click (I get the alert box and after that the popup) but doesn't work for middle (neither alert box nor popup). What am I missing?
$('a.external').live('click', function(e){
if( e.which <= 2 ) {
e.preventDefault();
alert ("inside if");
}
popUp.start(this);
});
To get this working fully in Firefox (40.0.3), I had to implement
.on('mouseup', fn)
, as follows:Use
mousedown
ormouseup
instead ofclick
. And (unless you are using a very old version of jQuery) use.on()
instead of.live()
:...where ideally you'd use a parent element much closer to the link than
document
.Demo: http://jsfiddle.net/7S2SQ/