jquery可排序和可放置 – 无法附加放置项?

我想将已删除的项目附加到可排序列表中的目标可放置框中,但我无法将放置的项目附加到特定元素中。

我的jquery,

$(".sortable").sortable({ update: function(){ // php update. } }).disableSelection(); $( ".droppable" ).droppable({ activeClass: "ui-state-hover", hoverClass: "ui-state-active", drop: function( event, ui ) { var targetElem = $(this).attr("id"); $( this ) .addClass( "ui-state-highlight" ) .find( "p" ) .html( "Dropped! inside " + targetElem ); alert(targetElem); var container = $( this ).find( "ul.dropped-items" ).css({border:"blue solid 1px"}); container.append(ui.draggable.clone()); ui.draggable.remove(); } }); 

被删除的项目应该附加到此元素中,

 

但它只是没有发生。 我错过了什么,我怎么能让它发挥作用?

jsfiddle测试页面 。

您可以删除元素上的绝对位置样式:

使用Javascript

 ... container.append(ui.draggable.clone().css({position: 'relative', left: 0, top: 0, width: 'auto', height: 'auto'})); ... 

演示

或者,添加样式以执行相同操作:

CSS

 .dropped-items li { position: relative !important; top: 0 !important; left: 0 !important; width: auto !important; height: auto !important; } 

演示