简体   繁体   English

使用右键单击激活ap:ajax事件

[英]activate a p:ajax event where using right click

I am working with JSF and Primefaces 5.2 ad i noticed that when you use a commandLink and add the event onclick with p:ajax like that you make a sort of selection on it 我正在使用JSFPrimefaces 5.2 ad,我注意到当您使用commandLink并将事件onclick与p:ajax添加在一起时,就像您在上面进行选择一样

<h:commandLink  id="commandLink">
<p:ajax event="click"/>
</h:commandLink>

my question is : i am working with javascript and what i want to do is when the user right click on the commandLink it activate the p:ajax specification (making the selection effect) 我的问题是:我正在使用javascript,我想做的是当用户右键单击commandLink它激活p:ajax规范(产生选择效果)

myJavascript myJavascript

document.oncontextmenu = function () { };

I know that my question is a little bit weird thank you. 我知道我的问题有点奇怪,谢谢。

You can bind the contextmenu event to your commandLink element like so. 您可以像这样将contextmenu事件绑定到您的commandLink元素。

var commandLink = document.getElementById('commandLink');

commandLink.addEventListener('contextmenu', function (event) {
  alert('commandLink was right clicked');
});

Demo 演示版

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM