Jquery-ui在drop上附加div并使附加的div droppable(嵌套)

时间:2017-03-20 07:35:18

标签: jquery-ui jquery-ui-sortable jquery-ui-draggable jquery-ui-droppable jquery-append

我需要拖动一个元素,并且在删除它时应该附加一个新的html div容器,并且附加的html div容器应该是droppable(嵌套)。我在这里附上小提琴文件。任何人都可以帮忙吗?

$('.dragItem').draggable({
  helper: 'clone',
  connectToSortable: "#column2,#column2 div"
});

$('.dragItem').sortable({
  containment: "parent"
});

$('#column2').sortable({
  placeholder: "highlight"
});

$('#column2').droppable({
  accept: '.dragItem',
  drop: function(event, ui) {
    var draggable = ui.draggable;

    var droppable = $(this);
    var drag = $('#column2').has(ui.draggable).length ? draggable : draggable.clone().draggable({});
    drag.appendTo(column2); 
    drag.sortable({
      placeholder: "highlight"
    });
    drag.droppable({
      accept: ".dragItem",
      drop: function (event, ui) {
        var draggable = ui.draggable;
        var droppable = $(this);
        var drag = $('#column2').has(ui.draggable).length ? draggable : draggable.clone().draggable({});
      }
    })
    drag.css({width:'', height: ''})
  }
});`

Js Fiddle

0 个答案:

没有答案