简体   繁体   中英

Javascript complex drag and drop sorting

I have a problem, i try to do complex sorting: example

    without group
    -child0

    -- GROUP1
    -child1
    -child2

    -- GROUP2
    -child3
    -child4

I need groups to be sorted (move all group down), with all childs, and childs of a group (make child4 upper then child3), and childs between groups (move child4 to group2 ), or make child out of group, can i make this with jquery ui sortable, or any ready solution?

Try this code: http://jsfiddle.net/lotusgodkk/28nMJ/201/

$(function () {
$('ul.mainlist').sortable({
    connectWith: 'ul',        
});
$('ul.sublist').sortable({
    connectWith: 'ul'
 });
});

HTML:

<ul class='mainlist'>
 <li>One (a)</li>
 <li>Two (a)</li>
 <li class="hasItems">Three (a)
     <ul class="sublist">
         <li>subitem1-1</li>
         <li>subitem1-2</li>
         <li>subitem1-3</li>
         <li>subitem1-4</li>
     </ul>
 </li>
 <li>Four (a)</li>
 <li class="hasItems">Five (a)
     <ul class="sublist">
        <li>subitem2-1</li>
        <li>subitem2-2</li>
        <li>subitem2-3</li>
        <li>subitem2-4</li>
    </ul>
 </li>
 </ul>
 <ul class='mainlist'>
  <li>1</li>
  <li>Two (b)</li>
  <li>Three (b)</li>
 </ul>

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