How can I get jQuery UI's Draggable and Sortable functions to work on the iPhone?

随声附和 提交于 2019-12-18 10:24:40

问题


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

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.

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.

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


回答1:


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);

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




回答2:


This is a demo of jquery ui 1.9pre: https://dl.dropbox.com/u/3872624/lab/touch/index.html

The jquery.mouse.ui.js file is working great for me.



来源:https://stackoverflow.com/questions/2870432/how-can-i-get-jquery-uis-draggable-and-sortable-functions-to-work-on-the-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!