create sub list of list item with no children

前端 未结 2 1887
后悔当初
后悔当初 2021-01-24 03:53

Little help need with jquery sortable.

I have a nested list like so:

  • root
相关标签:
2条回答
  • 2021-01-24 04:28

    I have managed a work around if anyone is interested....

    instead of the over and out options I have used start and end.

    start: function(event,ui)
           {
               $(this).find('li').not(':has(ul)').append('<ul><li></li></ul>');
               $(this).sortable('refresh');
           } ,
    stop:  function(event,ui)
           {
               $(this).find('li:empty').remove();
               $(this).find('ul:empty').remove();
               $(this).sortable('refresh')
           }
    

    If anyone has better solution please please please let us know...

    0 讨论(0)
  • 2021-01-24 04:34

    Actually , i don't have the same diposition of list as you , i saw inside an li you can have ul and li !

    > <li class="n-2">Academic
    >                 <ul>
    >                     <li class="n-5">Staff</li>
    >                     <li class="n-6">Courses</li>
    >                 </ul> 
    > </li>
    

    i only got :

     <ul id="sortable" class="connectedSortable">
        <li id='1' class="ui-state-default"><span> stuff ...</span></li>
        <li id='3' class="ui-state-default"><span> stuff ...</span></li>
        <ul id="sortable" class="connectedSortable">
             <li id='1' class="ui-state-default"><span> stuff ...</span></li>
             <ul id="sortable" class="connectedSortable">     
                    <li id='4' class="ui-state-default"><span> stuff ...</span></li>   
             </ul>
        </ul>
        <li id='2' class="ui-state-default"><span> stuff ...</span></li>  
    </ul> 
    

    in my jquery function i've got this in start :

    start: function(event,ui)
          {
         $(this).find('li').next().not('ul').after('<ul id="sortable" class="connectedSortable"><li class="hiddenli" style="height:0.1em;"></li></ul>');        
        $(this).sortable('refresh');
           }
    

    So i manage your version to work with my list^^ , but i get i also get a droppable zone after my current element i'm dragging, so i can placemy li as children but since the parent is the element which i'm dragging, it's not possible i'd like to remove the

  • creating after my element i'm dragging and that trigger the start event !

    For the update on sort i tried and failed using serialize don't know how to get the question and it's children and order it correctly i don't know where my

  • has been drop (which parent it has , and if it's in a list with other li which place it has , beceause as you can see on the screenshot, i got a number for each item (1-2-3-4) the last one represent the order in the list which has parent id=3 you see , i've been trying for days :(

0 讨论(0)
提交回复
热议问题