当一个对象从一个 div 拖放到另一个 div 时,li 中的格式只会更改为文本。我希望它具有相同的格式和样式,即删除后的“li”。
$(function() {
$( "#catalog ul" ).sortable({
zIndex: 10000,
revert: true
});
$( "#catalog" ).accordion();
$( "#catalog ul" ).draggable({
appendTo: "body",
helper: "clone",
zIndex: 10000
});
$( "#dialogIteration ol" ).droppable({
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
drop: function( event, ui ) {
$( this ).find( ".placeholder" ).remove();
$( "<li></li>" ).text( ui.draggable.text() ).appendTo( this );
}
}).sortable({
items: "li:not(.placeholder)",
sort: function() {
// gets added unintentionally by droppable interacting with sortable
// using connectWithSortable fixes this, but doesn't allow you to customize active/hoverClass options
$( this ).removeClass( "ui-state-default" );
}
});
$( "ul, li" ).disableSelection();
$("#dialogIteration").dialog();
});
演示:http: //jsfiddle.net/coolanuj/7683X/7/