dblclick 不适用于触摸设备
dblclick doesn't work on touch devices
让 dblclick
在触摸设备和 PC 浏览器上工作的最佳方式是什么
下面的代码在鼠标双击时工作得很好,但在 android 触摸设备上尝试时,不起作用。我应该怎么做?对此很陌生
$(document).on("dblclick","#table_discrepancy tr", function() {
var orderno = $(this).find("td:eq(0)").text();
var workorderno = $(this).find("td:eq(1)").text();
server('/get_customer_info/' + orderno, function(result){
var cus_name = result.name.replace(/^[\s]+/, '');
cus_name = cus_name.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
var phone_no = result.phoneno.replace(/^[\s]+/, '');
var email = result.email.replace(/^[\s]+/, '');
$('#customer_info_modal').modal('show');
$('#orderno_modal').html('Order# : ' + orderno);
$('#workorderno_modal').html('Work Order# : ' + workorderno);
$('#customer_name_modal').html('Name : ' + cus_name);
$('#customer_phoneno_modal').html('Phone#: ' + phone_no);
$('#customer_email_modal').html('Email: ' + email);
});
})
对于移动设备,我会使用特定于移动设备的事件,例如 taphold 而不是双击,因为它可能会给用户带来更原生的感觉。
您可以使用 jQuery 移动设备提供特定于移动设备的事件:
http://api.jquerymobile.com/category/events/
让 dblclick
在触摸设备和 PC 浏览器上工作的最佳方式是什么
下面的代码在鼠标双击时工作得很好,但在 android 触摸设备上尝试时,不起作用。我应该怎么做?对此很陌生
$(document).on("dblclick","#table_discrepancy tr", function() {
var orderno = $(this).find("td:eq(0)").text();
var workorderno = $(this).find("td:eq(1)").text();
server('/get_customer_info/' + orderno, function(result){
var cus_name = result.name.replace(/^[\s]+/, '');
cus_name = cus_name.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
var phone_no = result.phoneno.replace(/^[\s]+/, '');
var email = result.email.replace(/^[\s]+/, '');
$('#customer_info_modal').modal('show');
$('#orderno_modal').html('Order# : ' + orderno);
$('#workorderno_modal').html('Work Order# : ' + workorderno);
$('#customer_name_modal').html('Name : ' + cus_name);
$('#customer_phoneno_modal').html('Phone#: ' + phone_no);
$('#customer_email_modal').html('Email: ' + email);
});
})
对于移动设备,我会使用特定于移动设备的事件,例如 taphold 而不是双击,因为它可能会给用户带来更原生的感觉。
您可以使用 jQuery 移动设备提供特定于移动设备的事件: http://api.jquerymobile.com/category/events/