我想将已删除的项目附加到可排序列表中的目标可放置框中,但我无法将放置的项目附加到特定元素中。
我的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();
}
});
删除的项目应附加到此元素
中<ul class="dropped-items">
</ul>
但它没有发生。我错过了什么,我怎样才能让它发挥作用?
答案 0 :(得分:0)
您可以删除元素上的绝对位置样式:
Javascript
...
container.append(ui.draggable.clone().css({position: 'relative', left: 0, top: 0, width: 'auto', height: 'auto'}));
...
<强> Demo 强>
或者,添加样式以执行相同的操作:
<强> CSS 强>
.dropped-items li {
position: relative !important;
top: 0 !important;
left: 0 !important;
width: auto !important;
height: auto !important;
}
<强> Demo 强>