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

前端 未结 9 1709
一个人的身影
一个人的身影 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:14

    JEditable + jQuery UI Sortable + jquery.ui.touch-punch

    I have spent all day on this problem and I finally figured out the solution. The solution is very similar to kidwon's answer. However, I was using jeditable which dynamically creates input fields without class names. So I used this conditional statement instead of checking the class name:

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

    I think this is a better solution as it always uses the native functionality for any input or textarea fields.

提交回复
热议问题