medialize/jQuery-contextMenu — Issue #19: ignoreRightClick as a function?
Author: DataTables
Created: 2011-12-27 15:44:59+00:00
State: open

I wonder if you might consider adding the ability to pass in the "ignoreRightClick" option as a function? This would be useful for the case I'm looking at just now where I need to decide a menu 'show time' if the menu can be shown or not.

This is the code that I've added to allow this behaviour:

if (o.trigger != 'hover' && o.ignoreRightClick) {
$body.on('mousedown' + o.ns, o.selector, function (e) {
if ( typeof o.ignoreRightClick === 'function' ) {
if ( o.ignoreRightClick() ) {
handle.ignoreRightClick(e);
}
} else {
handle.ignoreRightClick(e);
}
} );
}

I realise that there is the "context-menu-disabled" class option - which would work for me, and I would imagine will work in most cases, but not interfering with the DOM for this ability might be nice, and allows me to do the calculation of if the menu should be shown or not on demand rather than whenever the logic elements that control that get updated.