Best solution for drag/drop category/subcategory?

2019-08-15 04:54发布

问题:

I have a very crude category list right now, but I'm wanting it to make it look and behave more like WordPress admin does it, where you can drag a category into another category.

Code looks like this:

<ul class="categories">
    <li>Real Estate</li>
    <li>Home Improvements</li>
    <ul class="categories">
        <li>Interior</li>
        <li>Exterior</li>
        <ul class="categories">
            <li>Exterior Subcat</li>
        </ul>
    </ul>
</ul>

I tried jQuery UI's sortable, and told it to sort <li>'s only, but the list items wouldn't drag outside of their parent <ul> list into another <ul> list.

Any ideas how I can accomplish this?

回答1:

See: Sortable + nested lists with jQuery UI 1.8.2

And plugin: http://mjsarfatti.com/sandbox/nestedSortable/