I want to append the dropped item into the targeted droppable box from the sortable list, but I cannot append the dropped item into the specific element.
My 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();
}
});
The dropped item should be appended into this element,
<ul class="dropped-items">
</ul>
But it just not happening. What have I missed and how can I make it work?
You could removing the absolute position styling on the element:
Javascript
...
container.append(ui.draggable.clone().css({position: 'relative', left: 0, top: 0, width: 'auto', height: 'auto'}));
...
Or, add the styling in to do the same:
CSS
.dropped-items li {
position: relative !important;
top: 0 !important;
left: 0 !important;
width: auto !important;
height: auto !important;
}