jQuery sortable obtain 2 elements being swapped

后端 未结 5 1811
温柔的废话
温柔的废话 2020-12-04 16:18

I cannot find out how to obtain destination element with jQuery UI sortable.

    $(\"#pages\").sortable({
        opacity: 0.6,
        update: function(even         


        
5条回答
  •  心在旅途
    2020-12-04 16:46

    Try using the serialize function which gives you a hash of the list of items in order.

    If you just need the item that the new item go dropped before you can do this:

    $("#pages").sortable({
        opacity: 0.6,
        update: function(event, ui) {
            var first = ui.item; // First element to swap
            var second = ui.item.prev();
            swapOnServer(first, second);
        }
    });
    

    second will be null if its at the start of the list.

提交回复
热议问题