简体   繁体   中英

jquery ui cannot add li to sortable list after all li dragged out or removed

I have a sortable set up like so:

            <ul id="sortable2" class="connectedSortable">
                <li class="ui-state-default">First <a title='delete' class="itemDelete text-right"><i class="fa fa-minus-circle" aria-hidden="true"></i></a></li>
                <li class="ui-state-default">Second <a title='delete' class="itemDelete"><i class="fa fa-minus-circle" aria-hidden="true"></i></a></li>
                <li class="ui-state-default">Third <a title='delete' class="itemDelete"><i class="fa fa-minus-circle" aria-hidden="true"></i></a></li>
            </ul>

When I have dragged all the child elements, the li 's out of the ul I cannot add anymore since there needs to be one li in place for me to add. How can I make it so that even when it is empty I can still drag from sortable1 into this sortable2.

您可以添加一个隐藏的“ <li>”,可用作拖动的工厂实体!

After looking at the dev tools console and witnessing the changes. I found that a simple
statement fixes this, even some words but a break is clean.

In dev tools after removing all elements i edited the html like so:

<ul id="sortable2" class="connectedSortable">
<br>
</ul>

Just add that br, you can even style on css... i think.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM