首页 > 解决方案 > JQuery - 拖放工作但如何禁用多选?

问题描述

我研究了一个我想用于项目的代码笔;https://jsfiddle.net/6mhndzr5/ 当我拖放单张卡片时,一切正常。

但是当我在卡片之间单击时,它会多选一列中的所有卡片。当在列之外定位这个多选时,我得到不同的错误;

jquery-2.2.4.min.js:3 Uncaught DOMException: Failed to execute 'insertBefore' on 'Node': The new child element contains the parent.
    at HTMLUListElement.<anonymous> (https://code.jquery.com/jquery-2.2.4.min.js:3:14925)
    at ua (https://code.jquery.com/jquery-2.2.4.min.js:3:13069)
    at n.fn.init.before (https://code.jquery.com/jquery-2.2.4.min.js:3:14862)
    at e.<computed>.<computed>._clear (https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js:12:18654)
    at e.<computed>.<computed>._clear (https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js:6:7987)
    at HTMLUListElement.<anonymous> (https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js:12:3225)
    at HTMLUListElement.d.complete (https://code.jquery.com/jquery-2.2.4.min.js:3:27958)
    at i (https://code.jquery.com/jquery-2.2.4.min.js:2:27151)
    at Object.fireWith [as resolveWith] (https://code.jquery.com/jquery-2.2.4.min.js:2:27914)
    at i (https://code.jquery.com/jquery-2.2.4.min.js:3:26240)

我只希望单选成为可能

有什么办法(可能是javascript,可能是css)来确保不可能进行多选?还是取消这个效果?

提前谢谢,Joost

标签: javascriptjquerydrag

解决方案


推荐阅读