jQuery UI可排序在iPAD中不起作用 [英] jQuery UI sortable not working in iPAD

查看:110
本文介绍了jQuery UI可排序在iPAD中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jquery UI可排序功能。这在浏览器中工作正常。但是在iPAD这样的触摸设备中却无法正常工作。下面是我正在使用的代码

I am using jquery UI sortable functionality. This works fine in browsers. But in touch device such as iPAD it is is not working. Below is the code i am using

<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="js/jquery.ui.touch-punch.js"></script> 

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

我的HTML是:

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

请尽快告诉我解决方案。提前谢谢。

Please let me know the solution asap. Thank you in advance.

推荐答案

好的,很明显,因为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>

这篇关于jQuery UI可排序在iPAD中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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