Problema de duplicación de jQuery UI multi DnD

I've been working up a drag and drop solution wherein a user would be able to select multiple items from a list of elements on the left, and drag them over simultaneously to a .sortable() area on the right based on este ejemplo.

The problem is that after the user were to select and drag more than one item, then follow that by dragging only one item, the single item would be duplicated.

Aquí hay un desglose:

  • User clicks multiple items, toggling a 'selected' class
  • User drags one of the selected items, all other selected items follow - user drops them in a container.
  • User then drags a single item, w/o toggling 'selected', to the container on the right, upon dropping, the item is duplicated.

I thought about altering the logic:

var selected = $('#ul-left .selected');
  if (selected.length === 0) {
    selected = $(this);
var container = $('<div></div>').attr('id', 'draggingContainer');
return container;

To say something like (pseudo-code):

if( selected >= 1){
  proceed as written above
} else {
  set the helper property to clone ( as if I would've done helper: 'clone',)

I am unsure if there is a way to manually do that, and besides, I am not sure I am even looking in the right direction - so to SO I go :)

Aquí está mi violín,

Thank you all for taking a look at this. Ken

preguntado el 01 de febrero de 12 a las 03:02

1 Respuestas

If you change your stop to add a refresh it should resolve this:

 stop:function (e, ui) {
          $('#wrapper ul li').removeClass('selected').css({'background-color':'#FFD'});
          $('#ul-right').sortable('refresh');// add this line

respondido 14 mar '12, 05:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.