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 8954397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:18:38+00:00 2026-06-15T14:18:38+00:00

Example code here: http://jsfiddle.net/pDuxe/ I have a droppable space with two draggable elements. I

  • 0

Example code here: http://jsfiddle.net/pDuxe/

I have a droppable space with two draggable elements. I have two issues:

  1. If the droppable area already has a draggable item in it, if I then try and drop a second item on top, I need it to be refused and to revert back to its original position.

  2. I can make use of the revert: 'invalid' code without problems, but if I place a draggable item into a droppable area and then want to move it back – it keeps reverting back to its place in the droppable area and not its original position.

So, how would I go about achieving those two situations?

  • 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-06-15T14:18:39+00:00Added an answer on June 15, 2026 at 2:18 pm

    What you can do is wrap your draggables in a div that you also make droppable:

    <div id="originalposition">
        <div id="draggable" class="ui-widget-content">
            <p>Drag me to my target</p>
        </div>
    
        <div id="draggable2" class="ui-widget-content">
            <p>Drag me to my target</p>
        </div>
    </div>
    

    Then you can do something like the following:

    $(function() {
        $("#draggable").draggable({ revert: 'invalid' });
        $("#draggable2").draggable({ revert: 'invalid' });
        $("#originalposition").droppable({
            drop: function(event,ui) {
                     $("#droppable").removeClass("ui-state-highlight").addClass("ui-widget-header").html("<p>Drop here</p>"); 
                  }
        });
        $("#droppable").droppable({
            drop: function(event, ui) {
                     $(this).addClass("ui-state-highlight").find("p").html("Dropped!");
                  },
            accept: function(dropElem) {
                    //dropElem was the dropped element, return true or false to accept/refuse it
                    return (!$(this).hasClass("ui-state-highlight") && $(dropElem).hasClass("ui-widget-content"));
                    }
        });
    });​
    

    Fiddle here.

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

Sidebar

Related Questions

I've created an example of the problem here: http://jsfiddle.net/JustinN/qWeLT/1/ My actual code is hooked
I am working on a little CSS3 menu. Live example here: http://jsfiddle.net/e592S/ (the code
Example here: http://jsfiddle.net/KyW6c/2/ I have an ordered list. Each list item is a project
so here is my example code - http://jsfiddle.net/JRqq3/ . It outputs true/false instead of
My full code is here: http://jsfiddle.net/HfNk9/13/ I am looking to this example jqueryUi autocomplete
Here is code example: http://jsfiddle.net/gubvw/3/ If you'll slowly change screen size by dragging sizer
I put my example code here http://jsfiddle.net/8epWm/2/ I want to enable zClip on an
Hi I have a code example available here: http://jsbin.com/oxoweh My problem is that I
I have a JSfiddle here: http://jsfiddle.net/mW9XD/ I'm struggling to get the amount of hours
Code Example of my problem: http://jsfiddle.net/x46RQ/ Goal I want the graph to be a

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.