jQuery Context Menu clashes with jQuery Draggable -
i'm trying jquery context menu jquery draggable rows in jqgrid.
the problem i'm having since added jquery context menu draggable action triggered on single click (as normal drag). looks little weird when rightclick row menu, , click outside on row (to discard menu) , row starts following cursor.
does have evt.stoppropagation();
in following snippet jquery context menu?
$(this).mousedown( function(e) { var evt = e; evt.stoppropagation(); $(this).mouseup( function(e) { e.stoppropagation(); var srcelement = $(this); $(this).unbind('mouseup'); if( evt.button == 2 ) { // hide context menus may showing $(".contextmenu").hide();
is there besides choosing between draggable or context menu?
i've had related problem--draggable items attached context menus not draggable. in case draggable item (a div element floating in larger containing div element) attached context menu dragged once--once drag complete, item no longer draggable until clicked in containing div. identical draggable items without context menus draggable. why clicking container restored draggability not know, did consistently.
thanks question pointing me in right direction, looked @ context menu code , modified follows, resolved problem:
jquery(this).mousedown( function(e) { var evt = e; if (e.button == 2) //added make compatible draggable evt.stoppropagation(); jquery(this).mouseup( function(e) { if (e.button == 2) //added make compatible draggable e.stoppropagation(); var srcelement = jquery(this);
adding check e.button == 2 stops propagation of right-click event, , draggable divs stay draggable, , context menu still works. i've tested in ie8 far, , don't know if solve problem, i'm interested know if does.
==edit==
per suggestion carl r compatibility chrome:
jquery(this).mousedown( function(e) { var evt = e; if (e.button != 2) return; //added make compatible draggable evt.stoppropagation(); jquery(this).mouseup( function(e) { e.stoppropagation(); var srcelement = jquery(this);
i've changed mode suggested, , it's working fine in ie8 way.
Comments
Post a Comment