4

「sortable」要素で並べ替えを無効にすることは可能ですが、並べ替えは「connectWith」でも機能しますか?

4

4 に答える 4

3

これは、list2 にドロップされていない場合、list1 の要素を元の場所に戻します (これをセルフドロップと呼びます)。

$("#list1").sortable({
    connectWith: ".connected-fields",
    beforeStop: function(event, ui) {
        // Don't allow resorting in list1... would call cancel here, but there is a jquery 1.7 bug so we
        // need to do the check here but do the cancel in "stop" below. @see http://bugs.jqueryui.com/ticket/6054
        $(this).sortable("option", "selfDrop", $(ui.placeholder).parent()[0] == this);
    },
    stop: function(event, ui) {
        var $sortable = $(this);
        if ($sortable.sortable("option", "selfDrop")) {
            $sortable.sortable('cancel');
            return;
        }
    }
});

$("#list2").sortable({
    connectWith: ".connected-fields"
});
于 2014-05-01T19:23:56.263 に答える
-1

左側の列の項目をセルフソートからキャンセルしても、connectWithに使用できます。

http://api.jqueryui.com/sortable/#option-cancel

于 2013-01-25T10:10:18.027 に答える
-1

このコードを次のように試すことができますdisable sortable:

$( ".selector" ).sortable( "disable" );

このリンクから詳細を学ぶことができます

そして、このメソッドのリンク。disable

于 2013-01-13T17:46:15.323 に答える