开发者

Combining jQuery Sortable and Drop Event

开发者 https://www.devze.com 2022-12-21 05:40 出处:网络
Basically I have a draggable list which is connected with a开发者_如何学Go sortable list. Works great except I need some sort of Drop event which I can use to change the list item after its dropped in

Basically I have a draggable list which is connected with a开发者_如何学Go sortable list. Works great except I need some sort of Drop event which I can use to change the list item after its dropped into the sortable list.

This works with .draggable -> .droppable but is there a fix for draggable -> .sortable?


Figured out, turns out there is a receive event which is the same as drop for the droppable.

$('.selector').sortable({
  receive: function(event, ui) { ... }
});


Why don't you use 2 sortable lists that are connected ? Then you can use the stop event

You can connect 2 lists by doing:

$("#sortable1, #sortable2").sortable({
        connectWith: '.connectedSortable'
}).disableSelection();

And then use the stop event

$( ".selector" ).sortable({
   stop: function(event, ui) { ... }
});

You can then change the dropped element by doing ui. (don't know this by heart but with the draggable plugin its ui.draggable)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号