I can not remove an item copied from one list to another (drag and drop)

5

I have the following code link .

My problem occurs as follows:

  • Add a Double Steppe in the list on the right.
  • Add a Simple Steppe in the list on the right.
  • Add a second Double Step in the list on the right.
  • Drag a Double Step to the "Remove"
  • Both Double Steppes are removed.
  • I have already identified that the problem is in the removal, as I have to remove the dateitem. I tried to pass dataitem.id and it still did not work because Id's are cloned by dragging some part from the list from left to right.

    I need the Id's to be different so when removing with dataitem.id it just removes a part.

        
    asked by anonymous 14.01.2015 / 14:59

    1 answer

    4

    The problem is that when you add the items to the left div the UID ( link ) of the object is the same. I mean the code:

    dataItem = listA_DS.getByUid(draggableElement.data("uid"));
    

    I did not find in the documentation a method for creating a new item from another. So I created it in the same hand. with the code:

    dataItem = listA_DS.getByUid(draggableElement.data("uid"));
    var novo = { id: dataItem.id, item: dataItem.item, img: dataItem.img };
    listB_DS.add(novo); 
    

    So it creates a new uid with each insertion and at the time of removing the problem of removing all ends.

    Code available at link

    Corrections requested by you at link

        
    14.01.2015 / 15:28