jquery UI可排序点击拖动不起作用

时间:2016-06-14 18:31:57

标签: javascript jquery css jquery-ui jquery-ui-sortable

为什么下面的代码没有启用我的UI,拖放启用,我的意思是可排序列表上的点击拖动不会在UI中显示任何更改。

$( ".table-col .pic img" ).sortable({
        containment : ".drag-drop-region",
        opacity: 0.35,
        tolerance: "intersect",
        connectWith: $(".list2"),
});
    $( ".table.secret-data-matched .table-row .table-col .pic" ).sortable({
        containment : ".drag-drop-region",
        opacity: 0.35,
        connectWith: $(".list1"),
        tolerance: "intersect",
        receive: function( event, ui ) {
            var target = event.target;
            droppedCntr++;
            increaseProgress(droppedCntr, correctSequence);
            var image = ui.draggable[0].src.split("/");
            var numPattern = new RegExp("[0-9]","g");
            var targetIndex = target.className.match(numPattern)[0]-1;
            var imageIndex = image[image.length-1].match(numPattern)[0];
            droppedSequence[targetIndex] = imageIndex;
        }
    });

这里list1和list2是属于的CSS类 $(“。table-col .pic img”) $(“。table.secret-data-matched .table-row .table-col .pic”) RESP。

1 个答案:

答案 0 :(得分:0)

我发现您正在对图片$( ".table-col .pic img" ).sortable()进行排序,但您不能这样做。

当您设置' sortable'对于一个元素,它的所有(直接)孩子都是可拖动/可排序的。看看我做的这个例子:https://jsfiddle.net/wietsedevries/d4fnhpcj/