EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on June 17, 2014, 04:27:21 AM



Title: prevent right click unless defined
Post by: devnull on June 17, 2014, 04:27:21 AM
Code:
$(document).on("contextmenu",function(e){e.preventDefault()});

This will of course prevent all right mouse clicks, but how can I prevent right mouse clicks UNLESS they have been defined within easyui using for example onContextMenu ?

I want to disable right mouse clicks in all areas, unless I have allowed them.
 


Title: Re: prevent right click unless defined
Post by: stworthy on June 17, 2014, 06:20:13 PM
The e.target value indicates what element is clicked. You can detect events bonded to it or other informations to determine if the event should be cancel.
Code:
$(document).on('contextmenu',function(e){
var target = e.target;
var events = ($.data(target,'events')||$._data(target,'events'))
//...
})