I have three blocks, "draggable", "sortable" and "droppable"
Inside "draggable" I have few elements built like this:
<li class="draggable ui-draggable ui-draggable-handle" id="header-1">
<img src="http://placehold.it/150x100">
</li>
These elements can be dragged into "sortable" and the elements dragged here can be dropped into "droppable" which is removing them from "sortable" it's basically deleting them.
How can I replace the image dropped into "sortable" with a new one without replacing the image from "draggable"?
Here's what I've tried:
I've tried adding this to the "draggable":
start: function (event, ui) {
$(this).addClass('testing');
}
This is adding ".testing" class to the current dragged item.
and I've added this to the "sortable" :
receive: function (event, ui) {
$('.testing').replaceWith('<img src="http://placehold.it/400x300">');
The problem here is that is replacing the whole markup including the "li" parent and I want to replace just the "img" element.
Here is a jsbin of how this works now.