且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery UI可排序在iPAD中不起作用

更新时间:2023-11-12 08:32:40

好的,很明显,因为jQuery UI库不包含触摸事件。如果你开发一个jQuery支持的网站,使用jQuery UI功能主义者,一些人不会在触摸启用移动设备。在您的情况下,您使用 sortable()方法就是一个很好的例子。

OK, It is obvious, because jQuery UI library does not include the touch events. If you develop a jQuery powered web site, with using jQuery UI functionalists some of are wont work in touch enable mobile devices. In your case that you have used sortable() method is good example.

有一个简单的解决方案,你可以实行。您可以使用 jQuery UI Touch Punch 插件来解决此问题(正如您所使用的那样)。

There is a simply solution you can implement. you can use a jQuery UI Touch Punch plugin for overcome this issue (As you used).

请确保您的 jquery.ui.touch-punch.js 文件加载与否。我认为如果它正确加载它应该工作。

Please make sure that your jquery.ui.touch-punch.js file load or not. I think if it is loading correctly it should work.

您也可以清除浏览器缓存。 (在iPad设置> Safari>清除Cookie和数据)

Also you can clear the browser cache. (in iPad Settings > Safari > Clear Cookies and Data)

以下是工作示例:

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>    
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>   
<script src="https://raw.github.com/furf/jquery-ui-touch-punch/master/jquery.ui.touch-punch.min.js"></script> 



<script>
  $(function() {
    $( ".documents" ).sortable();
    $( ".documents" ).disableSelection();
  });
</script>

<div id="bodyContainer">
      <ul class="documents">
        <li>1</li>
        <li>2</li>
        <li>3</li>
      </ul>
</div>