以编程方式将项目从一个可排序的连接列表移动到另一个
Move items from one sortable connected list to the other programmatically
我有两个可排序的连接列表 #left
和 #right
。我想在单击按钮时将所有元素从 #left
移动到 #right
。
$('#left li').each(function()
{
var $this = $(this);
$this.appendTo('#right');
});
以上函数移动项目,但未触发 receive
函数。
A JSFiddle 当前状态。
找到了手动触发 receive
事件的方法
$('#left li').each(function()
{
var $this = $(this);
$this.appendTo('#right');
// Trigger
$('#right').sortable('option', 'receive')(null, { item: $this });
});
新建JSFiddle
我有两个可排序的连接列表 #left
和 #right
。我想在单击按钮时将所有元素从 #left
移动到 #right
。
$('#left li').each(function()
{
var $this = $(this);
$this.appendTo('#right');
});
以上函数移动项目,但未触发 receive
函数。
A JSFiddle 当前状态。
找到了手动触发 receive
事件的方法
$('#left li').each(function()
{
var $this = $(this);
$this.appendTo('#right');
// Trigger
$('#right').sortable('option', 'receive')(null, { item: $this });
});
新建JSFiddle