【发布时间】:2015-07-08 07:54:07
【问题描述】:
从JQueryUI demos 的示例开始,我正在尝试禁用左侧列表的排序,并且左侧的项目必须被复制而不是移动, 有没有可能?
I've created a jsfiddle for it
$(function() {
$( "#sortable1, #sortable2" ).sortable({
connectWith: ".connectedSortable"
}).disableSelection();
});
通过使用可拖动和可放置交互,我可以更接近,但我无法像使用 sortable (jsfiddle here) 那样将元素拖放到特定位置:
$(function() {
$( "#sortable1 li" ).draggable({
appendTo: "body",
helper: "clone"
});
$( "#sortable2" ).droppable({
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
accept: ":not(.ui-sortable-helper)",
drop: function( event, ui ) {
$( this ).find( ".placeholder" ).remove();
$( "<li></li>" ).text( ui.draggable.text() ).appendTo( this );
}
}).sortable({
items: "li:not(.placeholder)",
sort: function() {
$( this ).removeClass( "ui-state-default" );
}
});
});
【问题讨论】:
标签: jquery jquery-ui drag-and-drop jquery-ui-sortable