Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining jQuery Sortable and Drop Event

Basically I have a draggable list which is connected with a 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?

like image 987
mike Avatar asked Feb 24 '10 03:02

mike


2 Answers

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

$('.selector').sortable({
  receive: function(event, ui) { ... }
});
like image 51
mike Avatar answered Nov 06 '22 10:11

mike


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)

like image 20
Olivier_s_j Avatar answered Nov 06 '22 10:11

Olivier_s_j