$('#list1').sortable({
update: function(event, ui){
//Some code that shouldn't be executed when an element is removed
},
remove: function(event, ui){
//Some code
}
});
$('#list2').sortable({
});
我想在重新排序列表时执行操作(触发更新),并在删除列表元素时执行另一个操作(但在这种情况下也会触发更新)。
答案 0 :(得分:1)
尚未对此进行测试但应该有效:
var delete = false;
$('#list1').sortable({
update: function(event, ui){
if (delete === true)
{
delete = false;
return false;
}
//Some code that shouldn't be executed when an element is removed
},
remove: function(event, ui){
delete = true;
//Some code
}
});
删除内容时设置标记,删除完成更新过程开始,如果标志为true,则跳过更新并重置标记。