在我看来,你需要touchstart
手柄绑定到网格并检测其引发了很短的时间以前touchstart
事件之后touchstart
。例如,您可以使用jQuery.data
来保存之前touchstart
事件的时间。
我修改您的演示,http://jsfiddle.net/OlegKi/yNw3C/12120/它使用下面的代码
$("#grid").bind("touchstart", function (e) {
var $this = $(this), now = new Date().getTime(),
lastTouchTime = $this.data("lastTouchTime") || now + 1,
timeInterval = now - lastTouchTime;
//console.log(e);
// the next line use constant 500 as 0.5 sec timeout between taps
if (timeInterval < 500 && timeInterval > 0) {
var $tr = $(e.target).closest("tr.jqgrow");
if ($tr.length > 0) {
//console.log($tr[0]);
alert("double touchstart on rowid=" + $tr.attr("id"));
} else {
alert("double touchstart");
}
}
$this.data("lastTouchTime", now);
});
的代码显示警报至少在Chrome中的三星Galaxy S4仿真模式
我发现这个https://stackoverflow.com/ question/8825144/detect-double-tap-on-ipad-or-iphone-screen-using-javascript;似乎你需要用vanilla JS编写你自己的doubletap检测函数; jquery mobile还有其他你喜欢的功能。 –