在基于 jquery-mobile 的 Web 应用程序中,我如何防止默认浏览器菜单显示在“点击保持”上......相反,我想显示一个自定义对话框页面......
下面提到的是我现在的代码..
$(".task_row").bind('taphold',function(event, ui){
event.preventDefault();
$("#slide_down_menu").trigger('click');
});
在基于 jquery-mobile 的 Web 应用程序中,我如何防止默认浏览器菜单显示在“点击保持”上......相反,我想显示一个自定义对话框页面......
下面提到的是我现在的代码..
$(".task_row").bind('taphold',function(event, ui){
event.preventDefault();
$("#slide_down_menu").trigger('click');
});
使用 CSS:
a {
-webkit-touch-callout: none !important;
}
不显示标准对话框
问题是您绑定的“taphold”事件是由 jQuery Mobile 触发的自定义事件,因此它与触发浏览器默认行为的事件不同。
如果您试图避免的默认菜单是允许您“打开”或“复制”网址的菜单,那么一种解决方案是不使用<a>
标签。如果你使用 span 或 div,你可以绑定一个 ontap 函数来改变浏览器的位置,并且你的 taphold 事件不会被默认行为中断。
我发现你必须禁用右键单击。
$(function(){
document.oncontextmenu = function() {return false;};
$(document).mousedown(function(e){
if ( e.button == 2 )
{
alert('Right mouse button!');
return false;
}
return true;
});
});
你很接近它。正确的代码是:
$('#ciytList li a ').bind('taphold', function(e) {
e.preventDefault();
return false;
} );
使用ontouchstart
事件呢?我很确定我已经使用它来防止发生默认的 iPad 交互。
$(".task_row").bind('touchstart', function(event, ui){
event.preventDefault();
$("#slide_down_menu").trigger('click');
});
我刚刚取消了链接并应用了 css 使其看起来像一个并使用了这个
$.mobile.changePage( "#main", { transition: "slideup"} );
但我已经将它绑定到显示删除按钮的单击事件...不再弹出菜单