Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6129413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:44:23+00:00 2026-05-23T16:44:23+00:00

i would like to load a page of objects that can be dragged on

  • 0

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

jQuery UI droppables – changing the image that's dropped

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:44:24+00:00Added an answer on May 23, 2026 at 4:44 pm

    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).

    1. Keep track of the original position of your draggable elements using .data() and the .drop() event of your droppable object:

      $("#drop").droppable({
          drop: function(event, ui) {
              if (!ui.draggable.data("originalPosition")) {
                  ui.draggable.data("originalPosition",
                      ui.draggable.data("draggable").originalPosition);
              }
          }
      });
      

      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).

    2. Create a function that you call that animates the dragged object back to its original position:

      function revertDraggable($selector) {
          $selector.each(function() {
              var $this = $(this),
                  position = $this.data("originalPosition");
      
              if (position) {
                  $this.animate({
                      left: position.left,
                      top: position.top
                  }, 500, function() {
                      $this.data("originalPosition", null);
                  });
              }
          });
      }
      

      Adjust the speed of the animation to your liking.

    3. Call that function from an event handler:

      $("#undo").click(function() {
          revertDraggable($(".drag"));
      });
      

    Here’s a working example: http://jsfiddle.net/v7N6w/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a web page and would like to load multiple
I have several PDF templates that I would like to load and modify and
I would like to detect when a page load request give to a UIWebView
I would like to check the load speed of each page in a particular
I have an assembly I would like to load from a sub-folder of the
I have a C# .Net 2.0CF application where I would like to load a
I have been toying with the modulino perl pattern and would like to load
I would like to be able to time a page load time in ASP.net
I have a List<string> collection that I would like to bind into my ListView
I would like to load a HTML document and modify it's text in PHP.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.