JQuery Draggable + Droppable + Sortable

I am sure that this was answered, but I can not find an example that would be appropriate for my situation. I have a list of images that you can drag and drop. I also have a div (id = "dropZone") that is set to droppable and sortable. I would like to run a function when the images are dragged and divided by div, but not when things are dropped onto the div from sorting. Here is what I tried:

stop: function() { $('#dropZone').prepend('<img src"img.png" />'); }

I added this to the dropdowns, however it will work even if they are dropped outside of droppable.

drop: function() { $('#dropZone').prepend('<img src="img.png" />'); }

Then I tried to add this to my droppable, but this adds the image both when dragging it and when sorting it.

Does anyone know what I need to do?

+2
source share
1 answer

The question is fuzzy, but it looks like you need a receive event from a sortable one.

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

http://jqueryui.com/demos/sortable/#connect-lists

This event will occur only when the item is received from another connected list.

0
source

All Articles