$(".container").on("contextmenu", ".photos-bottom .albums li", function(e) {
$('html').bind('click', function (event) {
alert(id);
});
return false;
});
when I right click (for the contextmenu) multiple times and then left click html once, it triggers the alert the number of times that I right clicked.
So if I right click once, then left click, it shows a popup once. If I right click three times, then left click, it shows the popup three times.
Why is this so?
$('html').unbind('click').bind('click')
fixed it.
Because your click event is being bound every time a context menu event occurs, you're actually adding an additional bind each time you right click. This is the reason for the ever-growing number of event executions.
You should either:
a) unbind the event when the context menu is closed, or
b) bind the click event outside of your contextmenu callback function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With