When using jQuery UI draggable+sortable the draggable element loses it’s css when dropped into sortable. Here’s my code and here’s a js fiddle demo
Try to put the draggable div into sortable and see that it loses it’s (in this case) background-color and border. Is it possible to prevent this?
<script>
$("#content").sortable({
revert:true
});
$( "#draggable" ).draggable({
connectToSortable: "#content",
revert: "invalid",
stop: function(event,ui) {
$(ui.item).attr('id','draggable');
}
});
</script>
<style>
#content {width:150px;}
#draggable {
width:50px;
height:50px;
border:1px solid red;
background-color:blue;}
.text {
min-height:100px;
width:100%;
border:1px solid red;
background-color:red;
}
</style>
<div id="content">
<div class="text">Item</div>
<div class="text">Item</div>
<div class="text">Item</div>
<div class="text">Item</div>
<div class="text">Item</div>
<div class="text">Item</div>
</div>
Or if you need the ID for other things, you can add this code to your sortable call:
Updated fiddle: http://jsfiddle.net/y6KHn/5/
see jquery: how to update draggable clone id?