0

I've built a sortable and connected with a draggable list just like plenty of others. However, if I don't use the clone helper on the draggable, the drag placeholder gets offset and the placement of it gets messed up. But when I do use clone, the cloned item doesn't have the item ID, which I was intending to pass back to the server on stop.

What's the best way to handle this? Should I use a data element on the li to store the 'value' of the li?

Second questions-- on stop I want to remove a class from the dropped element, and add a new class. However I can't figure out how to reference this element. this doesn't work, and the other objects passed in to the stop event are ui and event-- ui.helper looked like it may have the info I need, but this doesn't seem to work either.

Thanks!

Fiddle here:http://jsfiddle.net/37tdS/

3
  • 1
    You could continue to use clone but when you start the drag, copy the ID to a data() property attached to the object being dragged. On the second question, why not use the drop event on the droppable container to reference the dropped element via $(this)?
    – DevlshOne
    May 10, 2014 at 3:34
  • @DevlshOne-- thanks, you put me on the right track. I ended up using update rather than the drop event so I could apply styles to the cloned element rather than the original. New fiddle here: jsfiddle.net/37tdS/6
    – user101289
    May 10, 2014 at 17:39
  • Glad you got it worked out!
    – DevlshOne
    May 12, 2014 at 11:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.