medialize/jQuery-contextMenu — Issue #24: Build option/callback does not include event location
Author: rmacfadyen
Created: 2012-01-08 14:10:24+00:00
State: open

The option 'build'
{selector: ".awesome-menu",
build: function($trigger){
return {
callback: function(){},
items: {
foo: {name: "Foo"}
}
};
}};

does not pass the location the mouse event occurred at.

This would be useful for working with context menu for a CANVAS element where the context menu to be displayed depends on what the mouse is pointing at.

Changing line 205 from:
$.extend(true, e.data, defaults, e.data.build($currentTrigger) || {});

to:
$.extend(true, e.data, defaults, e.data.build($currentTrigger, { pageX: e.pageX, pageY: e.pageY }) || {});

Adds support for passing the location to the build function.