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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:32:43+00:00 2026-06-11T10:32:43+00:00

I am dragging an object inside a droppable that is also a draggable. After

  • 0

I am dragging an object inside a droppable that is also a draggable. After I drop the object, it is nested inside the droppable. Similarly if I drag the object outside droppable, it is not nested anymore.

However, if I routinely drag in and drag out of the droppable, the draggable ends up at a different position.

The code is at http://jsfiddle.net/sandeepy02/kTAL3/41/

You can replicate the issue by creating an object ‘Room’ and dragging ‘Table’ into it. Then move ‘Room’ and the ‘Table moves alongwith. However if you drag ‘table’ out of room and then drag in and drag out the ‘table’ it suddenly repositions itself.

EDIT
To clarify the code I am using to append the dragged item to the droppable is:

.droppable({
            drop: function(event, ui) {
                $(this).append(ui.draggable);
            },
            out: function(event, ui) {
                $("#boundaryContainer").append(ui.draggable);
            }

I tried various methods that save the position of the draggable before the drop in and drop out but they havent worked. the methods are:
METHOD 1:

.droppable({
            drop: function(event, ui) {
                var position = ui.draggable.offset();
                ui.draggable.appendTo($(this)).css(position);
            },
            out: function(event, ui) {
                var position = ui.draggable.offset();
                ui.draggable.appendTo("#boundaryContainer").css(position);
            }

METHOD 2:

.droppable({
            drop: function(event, ui) {
                var tempLeft= ui.draggable.position().left;
                var tempRight= ui.draggable.position().right;
                $(this).append(ui.draggable);
                ui.draggable.position().left = tempLeft;
                ui.draggable.position().right= tempRight;
            },
            out: function(event, ui) {
                var tempLeft= ui.draggable.position().left;
                var tempRight= ui.draggable.position().right;
                $("#boundaryContainer").append(ui.draggable);
                ui.draggable.position().left = tempLeft;
                ui.draggable.position().right= tempRight;
            }

METHOD 3 🙁

http://jsfiddle.net/sandeepy02/kTAL3/53/

  • 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-11T10:32:44+00:00Added an answer on June 11, 2026 at 10:32 am

    The issue here is that after you attach the second draggable to the droppable it becomes a part of it. Your tolerance here is the default one and the drag cursor is not repositioned. So regardless of whether you’re dragging the inner element, it actually never leaves the parent element because the cursor is always on top of it and it is a part of it’s parent element. In this case out never fires.

    You can test that behavior with the slight modification I made to your fiddle. (the modification is cursorAt: { top: -10, left: -10 } in the second draggable. Notice it still doesn’t work as you would expect that it would, because once you append the draggable back to the parent container elements are getting repositioned which is expected. You should think about keeping the droppables and the draggables in two separate parent containers, because then when you detach them you would not experience the issue with them repositioning relative one to another when they get attached back into the same parent container.

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

Sidebar

Related Questions

BACKGROUND: I have a draggable that I drop inside a droppable cum draggable. On
I want to display a custom image while dragging an object in a drag&drop
After dragging two tables in from one database, I switch to another and drag
When dragging an object, the user can drag in the x and y axes.
how can i disable/enable dragging, zooming in a 'map' object. also how can i
I have a draggable object, with that can be accepted in several droppables.. I
I am setting up a draggable interface using jquery to do my drag/drop operations.
I know in Java googleMap.draggable = false; in google.maps.MapOptions object specification disables dragging, but
i want to change the background of the draggable object after being dropped in
I am selecting time slot on dragging on Exam time cell. After selecting time

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.