Comments (14)
I'm not sure I understand what you are trying to achieve here. Do you want to prevent the menu from being triggered by mouse, so it can only be shown through your AJAX response handler? If so, why are you adding that mouseup handler?
from jquery-contextmenu.
Sorry if didn't explain correctly my problem.
My mouseup handler look likes this:
$(selector).bind('mouseup', function(e) {
if (e.button == 2) {
// An asynchronous AJAX call wich will execute '$(selector).contextmenu();' in the response.
}
}
This code doesn't work if I don't perform the fix describes in my first post.
To understant why, I tried to simplify my handler like this :
$(selector).bind('mouseup', function(e) {
if (e.button == 2) {
$(selector).contextmenu();
}
}
With this handler, the contextmenu is shown. But, the trigger take into account by the plugin is the standard right click trigger even if I have set ignoreRightClick=true option.
Indeed, the contextmenu code ignore my custom trigger because it is the first to call the event contextmenu and so the first to reach the test fixed in my first post (jquery.contextmenu.js line 190).
from jquery-contextmenu.
I still don't understand your problem. Setting the trigger to 'right' (which is default) and setting ignoreRightClick to true will prevent the contextMenu to ever be shown by a mouse click.
Here's a little demo - just pretend the setTimeout() would be some asynchronous ajax call.
from jquery-contextmenu.
I can't reproduce my AJAX problem using window.setTimeout(). I don't find why.
Nevertheless, I isolated what I suspect to be the problem in this demo http://jsfiddle.net/jpimag/CKw86/
In this demo, right or left click should trigger the menu at the top left.
It is not the case : right click trigger the menu on the mouse pointer.
This behavior shows that ignoreRightClick property ignore my custom trigger instead of ignoring default right click trigger.
Note : I don't find exactly why my AJAX code is different of a window.setTimeout() but fixing this demo fix also my AJAX code.
from jquery-contextmenu.
@jpimag - Your JSFiddle allows context menu on left click too ;-)
from jquery-contextmenu.
@bganov Yes, it was to illustrate that both click should have the same behavior.(open the menu on the left corner)
from jquery-contextmenu.
Awesome. For the future: If you're experiencing any kind of weird behavior with a fucked up browser like Internet Explorer, please state that in your bug report.
I can reproduce your problem (only) with Internet Explorer. And I believe I know why. For some reason the window.event
of your mousup
handler bleeds through .trigger()
to the internal contextmenu
handler.
Wrapping the contextMenu call in setTimeout()
leads to the window.event
being null.
I have yet to identify the source of this leak. But since contextMenu
doesn't know of window.event
, I'm guessing we hit a bug in jQuery (or at least an unexpected behavior).
For the time being wrap your call in a setTimeout()
to prevent window.event
of bleeding through: http://jsfiddle.net/rodneyrehm/CKw86/40/
from jquery-contextmenu.
I experienced the problem on Firefox 12, Chrome and IE 8 (windows XP). I will try your workaround. I keep you in touch.
from jquery-contextmenu.
Your demo works fine in my Firefox, Chrome, Safari. It fails in Internet Explorer and Opera 11.62.
As Opera doesn't know about window.event
I'm back to square one. I'll keep investigating.
from jquery-contextmenu.
Wow, what a ride… as it turns out, the order of contextmenu
events is different (and causing this problem). This fiddle shows that Firefox, Safari, Chrome run the sequence [mouse, manually], while Opera and Internet Explorer run the sequence [manually, mouse].
I'm not sure how I'm going to tackle this… but at least I now know what's going on.
from jquery-contextmenu.
Finally, I tried another way to trigger my menu.
I don't use ignoreRightClick parameter anymore. I simply intercept 'contextmenu' event before menucontext plugin.
$(document).on('contextmenu', selector, function(e) {
// interception of all classic contextmenu event
// Only custom contextmenu event are propagated to contextmenu plugin.
if (e.which != 'custom') {
// Open menu
e.preventDefault();
e.stopImmediatePropagation();
// An ajax request with $(selector).trigger(jQuery.Event('contextmenu', { which: 'custom', pageX: e.pageX, pageY: e.pageY})); in the response
}
});
It works fine on IE 7,8, Firefox 12, Chrome and Safari
Tell me if I you want I close the issue
Thanks for your time
from jquery-contextmenu.
Are you sure that event.which is the thing to roll with? Your solution is another workaround.
I think I know how to solve the problem within contextMenu. I'll look into it in the next couple of days.
You are free to close the issue, if you believe your workaround fixes things for you.
from jquery-contextmenu.
"next couple of days" came early.
I just released contextMenu 1.5.13, which should fix your problem. Note that the ignoreRightClick
option was dropped as it didn't do anything anymore.
from jquery-contextmenu.
I've just tested new version with success, thanks
from jquery-contextmenu.
Related Issues (20)
- How can i rebind the event and overwrite items callback ? HOT 1
- Disable Icons HOT 2
- Allow the selector receive an Element or JQueryNode
- Context menu jumps to the top of the screen HOT 1
- Display bug for a long list of submenu
- Seeking an official way to change context menu items style
- bug?: defining left click as trigger type triggers "oncontextmenu" of trigger button HOT 1
- get the element where the context menu was shown on right click HOT 2
- Issue with menu that is taller than the viewport with submenu items HOT 1
- Chrome v96.0.4664.45 HOT 1
- Do beta (v3) docs exist? The 'v3 Documentation' link goes to v2 Docs currently.
- Can't get Font Awesome icons working HOT 5
- use custom svg icons by gulp HOT 1
- Is it possible to hide a separator? HOT 1
- Animations do not work.
- Security - CVE-2021-41184: Upgrade embedded jQuery UI Position to 1.13+ (v2.x)
- Left click picking up parent as well as targeted child div HOT 1
- Context Menu Titles
- Append to an existing contextMenu?
- Jquery-contextMenu does not trigger the event on the new target element
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-contextmenu.