jquery.ui.touch.punch.js script is preventing input functionality on touch devices

前端 未结 9 1524
一个人的身影
一个人的身影 2021-02-01 06:38

It took me a little bit, but I figured out that I can\'t click on my inputs because of the touch.punch script I\'m using to enable jquery UI drag functionality on touch devices.

9条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-01 07:30

    I actually tried adding the lines which Danwilliger mentioned, it did not do the trick for me.

    What worked for me was

    //Check if element is an input or a textarea
    if ($(touch.target).is("input") || $(touch.target).is("textarea")) {
      event.stopPropagation();
      $(touch.target).focus();
    } else {
      event.preventDefault();
    }
    

    I am not really sure why the other answers posted did not work, but for anyone else out there if they have the same issue try my solution out :).

提交回复
热议问题