首页 > 解决方案 > Jquery Sortable 元素在排序过程中“卡住”

问题描述

我在这里有一种情况,我必须对用户可以对元素进行排序的 dom 元素进行排序。在某些情况下,当我尝试将其放在所需位置进行排序时,它会像下面一样卡住。

在此处输入图像描述

下面是我用于排序的代码。

 $(sortableSelector).sortable({
    placeholder: "sc-highlight",
    tolerance: "pointer",
    cursorAt: { top: 25, left: 25 },
    connectWith: connectWithItem,
    handle: ".scw-move",
    forcePlaceholderSize: true,
    refreshPositions: true,
    revert: 450,
    items: sortableItems,
    //cancel: '.sce-redactor-init',
    start: function (event, ui) {

        ui.helper.addClass('started-sorting');
        ui.item.addClass('started-sorting');
        var startedSCPPanel1 = $(ui.helper).closest('div[class^="scp-panel"]');
        startedSCPPanel=startedSCPPanel1;
    },
    change: function () {
        console.log('asdf');
    },
    stop: function (event, ui) {
        ui.item.removeClass('started-sorting');           
    },
    beforeStop:function( event, ui ) {
        $( this ).attr( "src", "replacement.png" );
    }
});

在某些情况下,“stop”和“beforeStop”事件都不会触发。在此先感谢您的帮助。

标签: jqueryjquery-ui

解决方案


推荐阅读