如何让 jQuery UI 的 Draggable 和 Sortable 函数在 iPhone 上工作? [英] How can I get jQuery UI's Draggable and Sortable functions to work on the iPhone?

查看:20
本文介绍了如何让 jQuery UI 的 Draggable 和 Sortable 函数在 iPhone 上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 JQuery UI 的页面;特别是 Sortable 交互.

I have a page that uses JQuery UI; in particular the Sortable interaction.

该页面适用于带有鼠标的桌面网络浏览器,但是我无法在 iPhone 上的 Mobile Safari 上使用拖放功能.任何拖动操作都只会滚动页面.

The page works fine for desktop web browsers with mice, however I can't get the drag-drop functionality to work on Mobile Safari on the iPhone. Any dragging action simply scrolls the page.

我页面上的功能与 Sortable Empty-Lists 极为相似jQuery UI 站点上的演示.此页面也无法在 iPhone 上运行.

The functionality on my page is extremely similar to the Sortable Empty-Lists demo on the JQuery UI site. This page also doesn't work on the iPhone.

有什么方法可以让拖放功能在 iPhone 上运行?

Is there any way to get the drag-drop functions working on the iPhone?

推荐答案

根据Mobile Safari docs不支持拖放,但可以模拟.由于基本上拖动手指会滚动浏览器,因此您必须禁用它.可以这样做:

According to the Mobile Safari docs drag and drop is not supported, but it can be simulated. Since basically dragging your finger along will scroll the browser you will have to disable this. That can be done like this:

$(document).bind('touchmove', function(e) {
   e.preventDefault();
}, false);

否则您必须处理的事件是 touchstarttouchmovetouchend.

Otherwise the event you will have to handle are touchstart, touchmove and touchend.

这篇关于如何让 jQuery UI 的 Draggable 和 Sortable 函数在 iPhone 上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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