Javascript 拖放以重新排序 HTML 列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10361779/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Drag and drop to reorder HTML lists
提问by nornagon
I have an app for which I would like to be able to drag and drop to reorder and arrange colours into groups. jQuery's sortablefor grids seems rather unresponsive and a little buggy. microjsrecommends kbjr's DragDrop, but that library has no concept of lists, only movable objects. Sproutcorehas a nice implementation, but I can't find a demo of it working for a grid.
我有一个应用程序,我希望能够对其进行拖放以重新排序并将颜色分组。jQuery对网格的排序似乎反应迟钝,而且有点问题。microjs推荐kbjr 的 DragDrop,但该库没有列表的概念,只有可移动的对象。Sproutcore有一个很好的实现,但我找不到它在网格上工作的演示。
My UI looks like this:
我的用户界面如下所示:
and I'd like users to be able to drag colours around within the groups as well as drag them between groups.
我希望用户能够在组内拖动颜色以及在组之间拖动颜色。
回答by Farhadi
回答by ahmohamed
Just a friendly update, since this question came up in the search. HTML5Sortable is no longer maintained. The recommended library is Sortable. Size: 12kb minified.
只是一个友好的更新,因为这个问题出现在搜索中。HTML5Sortable 不再维护。推荐的库是Sortable。大小:12kb 缩小。
Code:
代码:
var sortable = Sortable.create($('#items'));
Hope this help the next wanderer.
希望这对下一个流浪者有所帮助。