jquery Sortable connectWith 调用 update 方法两次

标签 jquery jquery-ui-sortable

在下面的代码中,当某个项目从列表 sortable1 移动到 sortable2 时,更新函数会被调用两次。虽然我只需要调用该函数一次:

$("#sortable1 tbody, #sortable2 tbody").sortable({
    connectWith: '.connectedSortable tbody',
    helper: fixHelper,
    handle : '.handle',
    update : function () {
        var order = $('#sortable1 tbody').sortable('serialize');
    }    
}).disableSelection();

最佳答案

回复:http://forum.jquery.com/topic/sortables-update-callback-and-connectwith

update: function(e,ui) {
    if (this === ui.item.parent()[0]) {
        //your code here
    }
}

关于jquery Sortable connectWith 调用 update 方法两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3492828/

相关文章:

jquery - 如何强制隐藏+空的 <div> 占用空间?

jQuery 可对分隔的部分进行排序

javascript - 我的 jQuery 链接不正确

jquery可拖动到可排序的 strip id中

jquery - 单击可排序列表时,文本区域焦点不起作用

jquery - 使用 jquery 的可排序将项目从一个列表复制到另一个列表

javascript - 为什么此图像 slider 在模式中不起作用?

javascript - a.nodeName is undefined Jquery错误

javascript - 显示到 ListView 问题

jquery - jquery(.jeditable) 可以用来自动下拉选择列表吗?