触发右键单击 [英] Trigger right-click

查看:161
本文介绍了触发右键单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 ContextMenu插件。所以在第一次右键单击这些元素时,我想:

I am trying to late-bind context menus to elements, using the ContextMenu plugin. So on the first right-click on those elements, I would like to :


  1. 拦截右键点击某个实时事件unetextmenuedclass,

  2. 确定数据('events')。contextmenu 是否存在,

  3. 如果没有,请附上上下文菜单(并更改类以避免重新抛出此实时进程),

  4. 重新抛出右键单击事件以显示正确的 - 点击。

  1. intercept the right-click through a live event on a certain "uncontextmenued" class,
  2. determine if the data('events').contextmenu exists,
  3. if not, attach the context-menu (and change the class to avoid re-throwing this live process),
  4. re-throw the right-click event to show the right-click.

我遇到了最后一项问题。 jQuery允许 .click() .trigger('click'),它模拟左键单击,但似乎没有办法通过触发器来触发右键单击事件。

I'm having trouble with the last item. jQuery allows to .click() or to .trigger('click'), which simulate a left-click, but there seems not to be a way to fire a right-click event through trigger.

或者有吗?

推荐答案

你可以通过

$('#element').trigger({
    type: 'mousedown',
    which: 3
});

http://api.jquery.com/trigger/#example-5

这篇关于触发右键单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆