jQuery可排序交换元素,而不是插入 [英] jQuery sortable swap elements instead insert

查看:99
本文介绍了jQuery可排序交换元素,而不是插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jQuery的初学者,但找不到解决方案:我使用的是 Sortable 与一张桌子. 但是默认的重新排序方法对我不利:我不想插入拖动的项目-我想交换拖动的项目和当前"项目(鼠标指针所在的位置).

I'm a beginner in jQuery and I can't found a solution: I'm using Sortable with a table. But the default re-ordering method isn't good for me: I don't want insert the dragged item - I want swap the dragged item and the "current" item (where the mouse pointer is).

 $(".timetable").sortable({
     items: "td.ora",
     sort: function(event,ui) {
            // what should I write here?
     });

我认为应该覆盖sort事件,但我不知道如何.

I think should overwrite the sort event but I don't know how.

推荐答案

此问题为Sortable提供了解决方案(请参阅问题底部的解决方法):

This question has a solution for Sortable (see the workaround at the bottom of the question):

jQuery sortable获得被交换的2个元素

但是我认为更优雅的解决方案是Swappable插件:

But I think the more elegant solution is the Swappable plugin:

http://www.eslinstructor.net/demo/swappable/swappable_home.html

这篇关于jQuery可排序交换元素,而不是插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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