Jquery 单击不适用于 ipad [英] Jquery click not working with ipad

查看:30
本文介绍了Jquery 单击不适用于 ipad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 Web 应用程序,它使用 Jquery blockUI 打开一个弹出窗口并执行一些操作.所有这些都可以在 Safari 和 IE 8 上正常工作.问题出在 Ipad 上.弹出窗口中的所有操作都没有响应.它只是停留在那个页面上.即使关闭也不起作用.我们还需要添加什么吗?这是打开页面并单击关闭事件的代码.

we have a web application which is using Jquery blockUI to open a pop up and do some action. All of this works fine on Safari, and IE 8. problem is with Ipad. none of the actions in pop up are responding. it just stays on that page. even close doesnot work. do we need to add anything else? here is the code that opens a page and click event for close.

<script>
$(document).ready(function() {
  $.ajaxSetup( {
           cache:false
   });

        $("#sendInviteDiv").load("invite.htm?action=view&pid="+pid);
            $.blockUI({ message: $('#sendInviteDiv'),
                centerY: 0,
                    css: {
                top:  ($(window).height() - 550) /2 + 'px',
                        left: ($(window).width() - 870) /2 + 'px',
                        width: '870px'
                }
            });
            //var ua = navigator.userAgent;
            //var event = (ua.match(/iPad/i)) ? "touchstart" : "click";
            //alert(ua);

            $('#closeInvite').click($.unblockUI);

    $('#inviteBtn').click(function() {
//script to load 
       //setPositionDetails('${formName}','inviteBtn');

       });
}


});


</script>

感谢指点.

javascript 已打开,Ipad Safari 设置中允许弹出窗口.

javascript is turned on and popups are allowed in Ipad Safari settings.

推荐答案

我通常使用

.bind("click touchstart", function(){

});

代替:

.click(function(){

});

这样你就绑定了正确的事件.它也更快,出于某种原因,触摸响应比点击快得多.

That way you are binding the the correct event. It's also quicker, the touch responds much faster than click for some reason.

这篇关于Jquery 单击不适用于 ipad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆