jQTouch 事件触发两次
jQTouch 有时会触发我的单击事件两次,这会导致在转换后立即显示的面板中单击另一个元素(通常是链接)。
这个问题已经在此处进行了相当广泛的讨论,但仍然没有我知道的一个很好的解决方案。在上面的论坛中,一位绅士建议使用以下代码作为解决方案,但我担心这对我不起作用,因为我正在使用滑动和点击事件:
allowClick = true;
function preventGhostClick(){
allowClick = false;
setTimeout(function(){
allowClick = true;
},800);
}
$('#element').bind('tap',function(){
if(!allowClick) return false;
app.utils.preventGhostClick();
// do stuff
});
是否有人对这个问题有任何经验以及比上面更好的解决方案?非常感谢!
jQTouch sometimes fires my click event two times which result in another element (often a link) getting clicked in the panel that shows immediately following a transition.
This issue has been discussed fairly extensively here but there is still not a good solution that I am aware of. In the forum sited above one gentleman suggests the following code as a solution but I am afraid that this will not work for me since I am using swipe and tap events:
allowClick = true;
function preventGhostClick(){
allowClick = false;
setTimeout(function(){
allowClick = true;
},800);
}
$('#element').bind('tap',function(){
if(!allowClick) return false;
app.utils.preventGhostClick();
// do stuff
});
Does anyone have any experience with this issue and any better solutions than the one above? Much thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过从点击事件更改为单击或触摸开始或触摸结束事件?我记得在 iPad 网络应用程序中遇到了与此非常相似的问题,并通过将我的事件更改为其中之一来修复它。抱歉我不记得具体了,但值得一试。
Have you tried changing from tap events to either click or touchstart or touchend events? I recall having a very similar problem to this with an iPad webapp and fixing it by changing my events to one of those. Sorry I don't remember specifically, but it's worth a shot.
我仅在 iPad 上看到此问题,可能与 webkit 的版本有关。我在网上看到了两种解决方案,我想分享一下。
I'm seeing this issue on iPad only, perhaps related to a version of webkit. I've seen two solutions on the web I wanted to share.