1

Currently I'm having a small problem with the demo at http://jsfiddle.net/nivea75ml/yCnh5/. Whenever I drag a pink box from the list to the grey area and later move it back, it covers another one in the same list.

How can this behaviour be avoided?

Reporter
  • 3,897
  • 5
  • 33
  • 47
Acubi
  • 2,793
  • 11
  • 41
  • 54

1 Answers1

2

Droppable and sortable

$('#draggableList').sortable({
    receive: function(event, ui) {
        var item = $('.ui-draggable-dragging');
        item.removeAttr("style");
        item.removeAttr('class');
        item.addClass('draggable');
    }
});
var $tab_items = $("#droppable").droppable({
    //accept: ".draggable",
    hoverClass: "ui-state-hover",
    drop: function(event, ui) {
        var item = $(this);

        var olditem = $(".draggable.ui-sortable-helper").clone();
        if (olditem[0] != null) {
            olditem.removeAttr('class');
            olditem.addClass('dragged');

            olditem.css({
                'position': 'absollute',
                'top': ui.offset.top,
                'left': ui.offset.left
            });
            olditem.draggable({
                connectToSortable: "#draggableList",
                helper: "original",
                revert: 'invalid'
            });

            ui.draggable.remove();
            $('#droppable').append(olditem).show("slow");
        }

    },
    out: function(event, ui) {}
});

http://jsfiddle.net/yCnh5/25/

zdrsh
  • 1,667
  • 1
  • 14
  • 26