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

  • SEARCH
  • Home
  • 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 9129439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:44:49+00:00 2026-06-17T07:44:49+00:00

Im trying to develop a small page that has the following functionality: Page will

  • 0

Im trying to develop a small page that has the following functionality:

  1. Page will have two divs: one being #origin, containing a lot of thumbnail images, and the second one will be #drop, where the images can be dropped on (up to 3 only).
  2. it needs to be possible to drag-drop the images from #drop back to origin.
  3. #drop needs to be sortable, since the order of the 3 selected images matter.
  4. When dropped on #drop, the images should align, as if they had original been displayed like that from the start.

I had never used jQuery before, and I even had a working page prototype before, where I already had the drag and drop between two containers through native HTML5 drag and drop events, but when I added the sortable() jquery functionality to #drop, the images could no longer be dragged back to #origin, which breaks my functionality.

So, I started over and wanted to implement both the drag & drop functionality as well as the sortable with jQuery. I’ve read pretty much the whole API for all draggable, droppable and sortable functionality, but I’m having trouble getting this to work. Not sure if it’s the settings I’m using for each functionality.

On the fiddle, you can see that the images become draggable and I can see the settings I specify in effect (opacity, cursor), but the images cant be dropped on #drop.

From what I understand, the combination of making images draggable, the images having a “draggable” class, and making #drop droppable with an accepts of “.draggable”, it should allow the most basic functionality, but even that doesn’t seem to take. Also I read that if both draggable and droppable have the same “scope” setting, it should also work, but it isn’t.

Here’s a simple version of the page’s code, plus a jsFiddle: http://jsfiddle.net/39khs/

Code:

css:

#origin {
  background-color: green;
}
#drop {
  background-color: red;
  min-height: 120px;
}

js:

$("img").draggable({ helper: "clone", opacity: 0.5, cursor: "crosshair", scope: "drop" });
$("#drop").droppable({ accept: ".draggable", scope: "drop"});
$("#drop").sortable();

html:

<div id="wrapper">
    <div id="origin" class="fbox">
        <img src="http://placehold.it/140x100" id="one" title="one" class="draggable" />
        <img src="http://placehold.it/140x100" id="two" title="two" class="draggable" />
        <img src="http://placehold.it/140x100" id="three" title="three" class="draggable" />
    </div>
  <p>test</p>
    <div id="drop" class="fbox">

    </div>
</div>

Any help is greatly appreciated.

  • 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-17T07:44:51+00:00Added an answer on June 17, 2026 at 7:44 am

    Here’s the fiddle with the final result:

    http://jsfiddle.net/39khs/82/

    The key was to handle the “drop” event and manually removing the dropped image from #origin and add it to #drop. That is actually what I was doing on the first implementation, but did not know how to do it exactly with jQuery:

     $(dropped).detach().css({top: 0,left: 0}).appendTo(droppedOn);
    

    I am not sure why jQuery does not really remove the dragged element from the old container and add it to the new one, but that is what had to be done for the newly dropped item to display correctly and not just exactly where it was dropped, disregarding css placing/styling.

    The key line was by @Barry Pitman on the following SO question:

    jQuery draggable + droppable: how to snap dropped element to dropped-on element

    UPDATE: I had some spare time today and wanted to check if it was possible with just sortable, and lo and behold, it was.

    http://jsfiddle.net/wj4ak/5/

    just two lines of code allow dragging and dropping from one container to another, and sorting the items. They do not need to be inside ul/ol lists at all. The one annoying thing is that I did not intend to make the items on the origin div sortable, but it’s something I can live with for now.

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

Sidebar

Related Questions

I'm trying to develop a small plugin that will do a sort-of auto-completion along
Hi I am trying to develop a small Wifi manager, and I have one
I have to develop a small application that will connect to a Linux server
I'm trying to develop small app that will be registered on PhoneStateListener and do
I am trying to develop a small app, that will store User's input about
I'm trying to develop a small application that tests how many requests per second
I am currently trying to develop a small simulation program in xna that takes
I am trying to develop a small app BusTracker which will list down a
I'm trying to develop a small Stripes project that allows the user to uoload
i'm trying to develop a small application that is able to track the position

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.