To change a newly inserted item, you must use a sortable receive event. However, to date, jQuery UI (1.8.11) has a well-known restriction / absence function, so you cannot easily access the cloned element from a receive event. The existing ui.item refers to the source element, not the copy.
, ( , DOM). , , . , /, ( ).
http://jsfiddle.net/3Gkrf/1/
HTML:
<ul>
<li id="test" class="dragme">Test</li>
</ul>
<ul class="sortme">
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
CSS
.dragme { border:1px solid silver; width:50px; height:50px; }
.newitem { background-color:yellow; }
JavaScript:
$(function(){
$(".sortme").sortable({
receive: function(){
$(this).find(".newitem").each(function(){
$(this).removeClass("newitem");
});
}
});
$(".dragme").draggable({
connectToSortable: ".sortme",
helper: "clone",
start: function(){
$(this).addClass("newitem");
},
stop: function(){
$(this).removeClass("newitem");
}
});
});
, , . , , , - .
stop: function(){
var clone = $(this).clone().appendTo("#wherever");
// do anything else with the clone variable here
}
, , , . , , .