Skip to content

Commit 1747a66

Browse files
committed
Fixed 'moving' menu
1 parent 4652ea9 commit 1747a66

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

jquery.contextmenu.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
options: {
2020
delegate: "[data-menu]", // selector
2121
menu: null, // selector or jQuery or a function returning such
22-
preventBuiltinMenu: true,
22+
// preventBuiltinMenu: true,
2323
// Events:
2424
beforeopen: $.noop, // menu about to open; return `false` to prevent opening
2525
blur: $.noop, // menu option lost focus
@@ -31,17 +31,17 @@
3131
select: $.noop // menu option was selected; return `false` to prevent closing
3232
},
3333
_create: function () {
34-
this.element.delegate(this.options.delegate, "click", $.proxy(this._openMenu, this));
35-
if(this.options.preventBuiltinMenu){
36-
this.element.delegate(this.options.delegate, "contextmenu.contextmenu", function(event){
37-
return false;
38-
});
39-
}
34+
this.element.delegate(this.options.delegate, "contextmenu.contextmenu", $.proxy(this._openMenu, this));
35+
// if(this.options.preventBuiltinMenu){
36+
// this.element.delegate(this.options.delegate, "contextmenu.contextmenu", function(event){
37+
// return false;
38+
// });
39+
// }
4040
this._trigger("init");
4141
},
4242
/** Return menu jQuery object. */
4343
_getMenu: function(){
44-
// this.options.menu may be a string, jQuery or a function returnig that.
44+
// this.options.menu may be a string, jQuery or a function returning that.
4545
var $menu = this.options.menu;
4646
if( $.isFunction($menu) ){
4747
$menu = $menu();
@@ -55,6 +55,7 @@
5555
},
5656
/** Open dropdown. */
5757
_openMenu: function(event){
58+
event.preventDefault();
5859
if( this._trigger("beforeopen", event) === false ){
5960
return false;
6061
}
@@ -88,7 +89,9 @@
8889
});
8990
$menu
9091
.css({
91-
position: "absolute"
92+
position: "absolute",
93+
left: 0,
94+
top: 0
9295
}).position({
9396
my: "left top",
9497
at: "left bottom",

0 commit comments

Comments
 (0)