Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery sortable, draggable onto a trash can object

I'm having a problem with sortable, draggable item when I drop it on a trash can object.
The code is in this jsfiddle. http://jsfiddle.net/queeg/sRAmW/1/

It's really easy to reproduce the issue in the jsfiddle:

  1. drag "bread" to sortableA" The "sortableA" box expands to allow the item to fit.

  2. drag "bread" to "Trash can" The trash can will expand to accept the item, then the item fades away.

  3. drag "bread" from "sortableA" to the "Trash can" The problem will show itself. The trash can does NOT expand and the item jumps to some other location before it fades out.

like image 896
Dave Lewis Avatar asked Mar 09 '12 20:03

Dave Lewis


2 Answers

A possible solution would be to remove the position: absolute from the draggable when dropped onto the trash can:

var element = ui.draggable.css('position', '');

DEMO

When coming from the #sortableX elements, they have this css rule applied, but not coming directly from one of the two lists.

like image 52
Didier Ghys Avatar answered Nov 02 '22 09:11

Didier Ghys


Calling $('#sortable, #sortable2').droppable(); seems to do the trick. See here.

like image 34
sinemetu1 Avatar answered Nov 02 '22 07:11

sinemetu1