View Full Version : jQuery Adding and removing between connected lists

11-12-2009, 02:20 PM
Greetings! I'm somewhat of a jquery noob, so please be kind . . .

I have a page where a user can drag options into a box and order them as they see fit. It's NDA for a client, unfortunately, but it's more or less built exactly on the brilliantly simple code stickman posted at: http://the-stickman.com/files/jquery/draggable-sortable.html

Which is great, but what if I want the user to be able to REMOVE an item from the box, just drag it out into the ether and have it disappear? It can still be dragged in from the initial lists, of course, but to remove it from the box with the same "dragging" interface seems natural -- only I can't see how to do it. Any ideas?

11-12-2009, 05:34 PM
I haven't done much with drag/drop (just a little experimentation) but it seems to me you can assign the outer div as a droppable object with a callback function that removes the object being dropped on it. Worth a shot...

11-13-2009, 09:49 PM
I wrapped one of the original "drag from" lists in a droppable div id, and added this to the bottom.

drop: function() {
return false;

As you may have guessed, it doesn't work. It removes the #droppable div.

I've tried some variations, but they just break it further. Suggestions?

11-13-2009, 11:59 PM
What if you created a little div with a graphic of a trash can on it and made that droppable? Then you can just remove anything that's dropped on it.

11-14-2009, 02:32 AM
No, I'm afraid that's still not working. Am I using the


11-14-2009, 06:44 AM
I dunno, is it selecting the correct element? If in doubt, you can always stick an id on the element and select it directly using the id.