EasyUI Forum
May 19, 2024, 08:31:53 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: context menu on draggable object [Solved]  (Read 4194 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« 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();
    }
})

« Last Edit: March 14, 2015, 06:36:00 PM by devnull » Logged

-- Licensed User --
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #1 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.
Logged

-- Licensed User --
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!