如何在iPad和其他触屏设备上使用jQuery-UI sortable功能?
http://jqueryui.com/demos/sortable/
我尝试使用event.preventDefault();
、event.cancelBubble=true;
和event.stopPropagation();
与touchmove
和scroll
事件,但结果是页面不再滚动。
有什么想法吗?
如何在iPad和其他触屏设备上使用jQuery-UI sortable功能?
http://jqueryui.com/demos/sortable/
我尝试使用event.preventDefault();
、event.cancelBubble=true;
和event.stopPropagation();
与touchmove
和scroll
事件,但结果是页面不再滚动。
有什么想法吗?
要在移动设备上实现 sortable
,我使用了 touch-punch,用法如下:
$("#target").sortable({
// option: 'value1',
// otherOption: 'value2',
});
$("#target").disableSelection();
disableSelection();
。$("#sortableDivId").sortable({
handle: ".ui-icon"
});
在这里,您需要传递您想要作为初始化器的类名。
var time1Sec;
var ifProceed = false, timerStart = false;
mouseProto._touchStart = function (event) {
var self = this;
// Ignore the event if another widget is already being handled
if (touchHandled || !self._mouseCapture(event.originalEvent.changedTouches[0])) {
return;
}
if (!timerStart) {
time1Sec = setTimeout(function () {
ifProceed = true;
}, 1000);
timerStart=true;
}
if (ifProceed) {
// Set the flag to prevent other widgets from inheriting the touch event
touchHandled = true;
// Track movement to determine if interaction was a click
self._touchMoved = false;
// Simulate the mouseover event
simulateMouseEvent(event, 'mouseover');
// Simulate the mousemove event
simulateMouseEvent(event, 'mousemove');
// Simulate the mousedown event
simulateMouseEvent(event, 'mousedown');
ifProceed = false;
timerStart=false;
clearTimeout(time1Sec);
}
};
目前,最受欢迎的答案链接已经失效。
要在移动设备上使用jQuery UI Sortable,请执行以下操作:
有关更多信息,请查看此链接。