jQuery UI Sortable and two connected lists

前端 未结 4 514
慢半拍i
慢半拍i 2020-12-23 23:17

I am trying to put together the following with jQuery and Sortable: There are two cases that I need to grab:

  • A: move an item within the same l
4条回答
  •  长情又很酷
    2020-12-23 23:41

    I am also looking for same... but all above solutions not working as I want. From jquery-ui connected sortable list get serialize/toarray values of two list if item moved from one to another.

    Finally I figure it out with single method which is update.

    function getSortableOrder(sortableList,ui){
      var listItems = {}
    listItems['sortable'] = sortableList.sortable('toArray');
      if(ui.sender!=null)
        listItems['sender'] = ui.sender.sortable('toArray');
      console.log(listItems);
    }
    $('.sortable[sortable="true"]').sortable({
                        connectWith:".sortable",
                        placeholder: "ui-state-highlight",
                        update: function(ev, ui) {
                          getSortableOrder($(this),ui);
                        }
                    });
    
    
    
    • item 1
    • item 2
    • item 3

    • item 4
    • item 5
    • item 6

提交回复
热议问题