0
votes

I am looking to create a tool where I can drag an image from one div to another and on drop, the following to happen:

1 - The dragged image returns to where it came from 2 - A series of controls are added within a container

Similar to https://formbuilder.online/ when a textbox is added to the form.

I understand how to perform the drag (i.e. make the item draggable) and I can understand the drop event. I'm struggling to return the dropped object back to it's original location.

The overall aim is to drop a list item into a sortable list so I can reorder the items (it's similar to the formbuilder linked above, but for a custom application, nothing to do with forms.

I'm just not sure what I need to put into my dropEvent function to return the dragged item to it's location. I can use jQuery append to add the list item containing the controls I want to the list, so that should be fine, it's just the returning the item to where it came from.

2

2 Answers

0
votes

Sory, have just seen the documentation and the revert option when making an item draggable.

0
votes

You might wanna try jQuery Sortable: https://jqueryui.com/sortable/