如何将两个列表合并为可拖动、可放置和可排序?
我有两个清单。开始时,只有第一个列表具有可见元素,第二个列表仅以一个隐藏元素开始。当我拖动时,我会搜索空列表以查找是否只有一个元素以及它是否通过 CSS 隐藏。如果是这样,我从源列表中删除该元素并将其添加到第二个列表中。另外,我需要第二个列表可以排序,但目前下面显示的代码不起作用。
$(function(){
$( '.draggable_base_menu_item' ).draggable( {
containment: '#submenu',
stack: '#submenu ul li',
cursor: 'move',
revert: false,
connectToSortable: '.droppable_menu_item_area'
} );
$( '.droppable_menu_item_area' ).sortable( {
tolerance: 'pointer',
items: 'li',
receive: function( event, ui )
{
$(ui.draggable).appendTo( this );
}
} ).disableSelection();
});
任何人都可以提出任何建议吗?
I have two lists. At start only the first one has visible elements, the second list starts with only one hidden element. When I drag, I search empty list to find if there is only one element and if it's hidden through CSS. If so, I remove the element from the source list and add it to the second one. Also I need second list to be sortable, but at the moment with the code shown below it doesn't work.
$(function(){
$( '.draggable_base_menu_item' ).draggable( {
containment: '#submenu',
stack: '#submenu ul li',
cursor: 'move',
revert: false,
connectToSortable: '.droppable_menu_item_area'
} );
$( '.droppable_menu_item_area' ).sortable( {
tolerance: 'pointer',
items: 'li',
receive: function( event, ui )
{
$(ui.draggable).appendTo( this );
}
} ).disableSelection();
});
Can anyone suggest anything?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可排序已经是可拖动的。使用带有连接列表的可排序:
http://jqueryui.com/sortable/#connect-lists
Sortables are already draggables. Use sortables with connected lists:
http://jqueryui.com/sortable/#connect-lists