相关疑难解决方法(0)

jQuery sortable connectWith多个列表

我有两个列表,每个列表中有8个列表元素.我想将任一元素拖到任一列表中,并将两个列表的总顺序放在一起.

目前,该订单被归类为两个单独的可排序列表:

[0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7]
Run Code Online (Sandbox Code Playgroud)

但是我希望它(显然是按元素的顺序):

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
Run Code Online (Sandbox Code Playgroud)

该参数connectWith似乎根本不起作用,我无法将元素拖到其他列表中.

$(document).ready(function() {
    $('#list-1, #list-2').sortable({
        connectWith: '.group',
        update: function(event, ui) {
            var orders = new Array();
            $('#console').html('<b>posts[id] = pos:</b><br>');
            $('.group li').each(function(i) {
                var order = $(this).index();               
                var id = $(this).attr('data-post-id');
                orders.push(order);
            });
            console.log(orders)
        }
    });

});
Run Code Online (Sandbox Code Playgroud)

我创建了一个jsFiddle

任何人都可以提出任何建议,为什么这不起作用?

jquery jquery-ui jquery-ui-sortable

4
推荐指数
1
解决办法
8280
查看次数

标签 统计

jquery ×1

jquery-ui ×1

jquery-ui-sortable ×1