JQuery UI Sort - two lists and the prohibition of sorting a list of internal origin

I have a simple jquery ui example. Basically I have to list the elements, each of which is sorted. And I want to do the following: Cancel sorting of the same list. for example, if I clicked an item at position one in the list one, and then dragged it to position 6 and dropped it. I want to prevent this, but if I delete an item in list two, that's fine.

I don’t know how to specify to match my requests. ConnectWith seems not sufficient:

$("#sortable").sortable({
    connectWith: [$('#sortable2')]
});

$("#sortable2").sortable({
    connectWith: [$('#sortable')]
});

here is an example:

http://jsfiddle.net/sQeZE/3/

+5
source share
2 answers

, , receive stop ( ). receive , . , . stop :

var blocksort = true;
//Using jQuery 1.6.4, but use `.on` when available
$("#sortable, #sortable2").bind('sortreceive', function () {
    blockSort = false;
}).bind('sortstop', function (e) {
    if (blockSort) {
        e.preventDefault();
    }
    blockSort = true;
});

http://jsfiddle.net/sQeZE/5/

+2

, , :

$("#sortable").sortable({
    connectWith: [$('#sortable2')],
    containment: $('#sortable2') });

$("#sortable2").sortable({
    connectWith: [$('#sortable')],
    containment: $('#sortable') });

, #sortable #sortable2,

+1

All Articles