i would like to load a page of objects that can be dragged on to a map/div but would like to have a clear/undo button? is this possible with jquery?
you can see code in a previous question
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is possible with a simple call to
.animate()(which, after all, is all jQueryUI is doing) and some logic to keep track of the original position of the element you’re dragging (which jQueryUI already partially handles for you).Keep track of the original position of your draggable elements using
.data()and the.drop()event of yourdroppableobject:Basically this just sets data called “originalPosition” on the dragged element. This assumes that you’re able to keep dragging the element inside a valid drop zone (and so it doesn’t overwrite the original position after you keep dragging).
Create a function that you call that animates the dragged object back to its original position:
Adjust the speed of the animation to your liking.
Call that function from an event handler:
Here’s a working example: http://jsfiddle.net/v7N6w/