javascript - IE generates spurious mouse click event for absolute-positioned div when dragging child element -
in jsfiddle below, click link 'click show menu' display absolute-positioned div jscrollpane attached. start dragging scrollbar thumb allow mouse wander little right of scrollbar, , release mouse. in ie (versions 8,9,10) click event generated on document, triggers our code hide menu. in other browsers i've tested (firefox, chrome, safari) no such click event generated on document , menu remains displayed (as desired).
in our web app, want clicks outside menu (i.e., reach document) hide menu. however, don't want menu hidden side-effect of drag initiated within scrollpane itself.
is there simple workaround avoid issue? can jscrollpane updated somehow avoid problem?
$(document).ready(function () { $('.scroll-pane').jscrollpane(); $('#menu').click(function () { console.info('menu clicked'); var api = $('.scroll-pane').show().data('jsp'); api.reinitialise(); return false; }); $(document).click(function () { console.info('document clicked'); $('.scroll-pane').hide(); }); $('.scroll-pane').bind('mousedown', function (ev) { console.info('scroll pane mousedown'); }).bind('mouseup', function (ev) { console.info('scroll pane mouseup'); }).bind('click', function (ev) { console.info('scroll pane click'); return false; }); });
i encountered similar click
event inconsistencies well. turns out ie fires click
event whatever element mouse on during mouseup
, , not element on when click first started mousedown
.
https://stackoverflow.com/a/4606960/17803
in other words - if click down while on element a, move mouse element b, , release, in ie get:
mousedown
amouseup
bclick
b
Comments
Post a Comment