jQuery Mobile:用vclick事件替换click事件 [英] jQuery Mobile : replace click event by vclick event

查看:202
本文介绍了jQuery Mobile:用vclick事件替换click事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jQuery mobile中是否可以用vclick事件替换所有click事件?

Is there a way to replace all click event by vclick event in jQuery mobile?

到目前为止,我发现的唯一解决方案是注册一个vclick事件,如下所示

The only solution I've found so far is to register a vclick event as below

$('a').bind("vclick", function (ev) {
  // Do Some stuff
  ev.preventDefault();
});

问题在于此解决方案无法阻止jQuery移动点击事件触发,因此两次触发了点击

The problem is that this solution doesn't prevent jQuery mobile click event to fire so clicks are triggered twice

推荐答案

由于某种原因,我可以进行以下操作:

For some reason, I got the following to work:

$('a').bind('vclick click',function(e){
  e.preventDefault();
   //do some stuff//
 })

如果没有e.preventDefault(),则事件触发两次.有了它,它只会发射一次(但是会发射)

Without the e.preventDefault() the event fires twice. With it, it only fires once (but it does fire)

这与您所说的相似,但可能涵盖所有内容.

This is similar to what you stated, but may be more all encompassing.

这篇关于jQuery Mobile:用vclick事件替换click事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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