EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on March 14, 2015, 06:16:38 PM



Title: context menu on draggable object [Solved]
Post by: devnull on March 14, 2015, 06:16:38 PM
I am trying to setup a context menu on a list item which is draggable.

Problem is the mousedown event is triggered in onBeforeDrag before the contextmenu() event and therefore I cannot prevent the drag, and fire the menu;

Code:
  $('ul.ulbar li').on('contextmenu', function(e){
    e.preventDefault();
    e.stopPropagation();
    do something else .....
  });

('ul.ulbar li ').draggable({    
    onBeforeDrag: function(e){
      if(e.type != 'contextmenu') return true;
      e.preventDefault();
      e.stopPropagation();
    }
})



Title: Re: context menu on draggable object
Post by: devnull on March 14, 2015, 06:31:41 PM
OK, I managed to solve this by using the which attribute:

Code:
('ul.ulbar li ').draggable({    
    onBeforeDrag: function(e){
      if(e.which == 3) return false;
    }
})

This might be useful to others.