I want to add draggable items to a sortable list, which works fine in my example on http://jsbin.com/ipese5/35
Problem is that I want to update id of the cloned item when dragged to the sortable list. Strange thing is that the following code updates the id to "new-id" in de ui object (as I can see in my console), but the id is not changed on the actual page html. Anyone has a solution?
$( "#init .block" ).draggable({
helper: "clone",
connectToSortable: ".list"
});
$(".list").sortable({
connectWith: ".list",
receive: function(event, ui) {
$(ui.helper).attr("id","new-id");
console.log(ui);
// surprisingly the next line works fine, but is not neccesary
// $(ui.item).attr("id","new-id");
}
});
<div id="init">
<div id="new" class="block">Drag me</div>
<div id="new" class="block">Drag me</div>
<div id="new" class="block">Drag me</div>
</div>
<div class="list">
<div class="block">Sort me</div>
<div class="block">Sort me</div>
</div>