Jquery click not working with ipad

后端 未结 11 861
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 12:38

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 ac

相关标签:
11条回答
  • 2020-12-02 12:54

    Probably rather than defining both the events click and touch you could define a an handler which will look if the device will work with click or touch.

    var handleClick= 'ontouchstart' in document.documentElement ? 'touchstart': 'click';
    $(document).on(handleClick,'.button',function(){
    alert('Click is now working with touch and click both');
    });
    
    0 讨论(0)
  • 2020-12-02 12:58

    I had a span that would create a popup. If I used "click touchstart" it would trigger parts of the popup during the touchend. I fixed this by making the span "click touchend".

    0 讨论(0)
  • 2020-12-02 13:03

    I found that when I made my binding more specific, it began to work on iOS. I had:

    $(document).on('click tap', 'span.clickable', function(e){ ... });
    

    When I changed it to:

    $("div.content").on('click tap', 'span.clickable', function(e){ ... });
    

    iOS began responding.

    0 讨论(0)
  • 2020-12-02 13:04

    I usually use

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

    instead of:

    .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.

    0 讨论(0)
  • 2020-12-02 13:04

    Thanks to the previous commenters I found all the following worked for me:

    Either adding an onclick stub to the element

    onclick="void(0);" 
    

    or user a cursor pointer style

    style="cursor:pointer;"
    

    or as in my existing code my jquery code needed tap added

    $(document).on('click tap','.ciAddLike',function(event)
    {
        alert('like added!'); // stopped working in ios safari until tap added
    });
    

    I am adding a cross-reference back to the Apple Docs for those interested. See Apple Docs:Making Events Clickable

    (I'm not sure exactly when my hybrid app stopped processing clicks but I seem to remember they worked iOS 7 and earlier.)

    0 讨论(0)
提交回复
热议问题