Knockout.js nested sortable bindings

倾然丶 夕夏残阳落幕 提交于 2019-12-05 06:27:25

I don't know your exact structure, but you can use the connectClass option to control which sortable lists are connected. For example, if you did this:

<ul data-bind="sortable: { data: buckets, connectClass: 'buckets' }">
    <li>
        <span data-bind="text: name"></span>
        <ul data-bind="sortable: { data: items, connectClass: 'items' }">
            <li data-bind="text: name"></li>
        </ul>
    </li>
</ul>

You would only be able to drop a bucket within buckets and an item within items. The plugin automatically adds the class to the parent element.

Here is a sample: http://jsfiddle.net/rniemeyer/YaLgL/

If you did not want to be able to sort items between buckets, then you could apply a unique connectClass to each like:

http://jsfiddle.net/rniemeyer/czNe8/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!