在我看來,你需要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還有其他你喜歡的功能。 –