开发者

How to disable jquery connected sortables on the go?

开发者 https://www.devze.com 2023-02-14 12:03 出处:网络
Given two simplest connected sortables, Problem (updated). when a draggable item le开发者_如何学Pythonaves its container, the container should not accept it back while the item is still being dragged

Given two simplest connected sortables,

Problem (updated). when a draggable item le开发者_如何学Pythonaves its container, the container should not accept it back while the item is still being dragged (as if the container is disabled). On the DOM level, the placeholder should not move back to the original container.

How can this be accomplished?


The code in this jsfiddle is not working as expected, but should be a good starting point.


Maybe this will do...

http://jsfiddle.net/pMYft/15/

$("#origin").sortable({
    connectWith: '.destination'
}).disableSelection();
$(".destination").sortable({
    connectWith: ".destination",
}).disableSelection();

the origin list can drag to either of the destination lists but not back to itself.


I was working on your code on jsfiddle and i changed it

$("ul").sortable({
    connectWith: "ul",
    items: "li:not(.ui-state-disabled)",
    cancel: "ui-state-disabled",
    out: function (e, ui) {
        ui.item.addClass("ui-state-disabled");       
    }
}).disableSelection();
0

精彩评论

暂无评论...
验证码 换一张
取 消