Jquery可排序更新事件只能调用一次?

R. *_*kan 5 jquery draggable jquery-ui-sortable

我正在尝试使用Jquery&Php进行类别更改.我没问题.我的问题是,当调用update事件时,它返回2个结果.拖动父项的1个结果,Dropped Parent的一个结果.我想只打电话给父母的身份.这是我的脚本:

$("#gallery ul").sortable({
    connectWith: '.dropBox',
    opacity: 0.35,
    scroll: true, 
    scrollSensitivity: 100,
    //handle: '.move',
    helper: 'clone',
    containment:'#gallery',
    accept:'#gallery > .photo',
    revert: true,
    update: function(event, ui){
        params = 'c=' + $(this).attr('id') + '&id=' + ui.item.attr('id');

        $.ajax({
            type: 'POST',
            url: 'processData.php',
            data: params,
            error:function(){
                alert("Error!");
            },
            success:function(data){
                $("#serverResponse").html(data);
            }
        });
    }
}).disableSelection();
Run Code Online (Sandbox Code Playgroud)

你能帮帮我们吗?

Saf*_*Ali 7

使用update,stopreceive事件,例如

$(function() {
    position_updated = false; //flag bit

    $(".sortable").sortable({
        connectWith: ".sortable",

        update: function(event, ui) {
            position_updated = !ui.sender; //if no sender, set sortWithin flag to true
        },

        stop: function(event, ui) {
            if (position_updated) {

                //code

                position_updated = false;
            }
        },

        receive: function(event, ui) {
            // code
        }

    }).disableSelection();
});
Run Code Online (Sandbox Code Playgroud)