How do I duplicate item when using jquery sortable?

后端 未结 6 610
孤街浪徒
孤街浪徒 2020-11-29 20:16

I am using this method http://jqueryui.com/demos/sortable/#connect-lists to connect two lists that i have. I want to be able to drag from list A to list B but when the item

6条回答
  •  眼角桃花
    2020-11-29 20:51

    The answer of abuser2582707 works best for me. Except one error: You need to change the return to

    return li.item.clone();
    

    So it should be:

    $("#sortable2, #sortable1").sortable({
        connectWith: ".connectedSortable",
        remove: function (e, li) {
            li.item.clone().insertAfter(li.item);
            $(this).sortable('cancel');
            return li.item.clone();
        }
    }).disableSelection();
    

提交回复
热议问题