2017-05-10 2 views
0

Ich verwende jQuery Sortable. Das Ziehen und Ablegen von Elementen in einer Liste auf mehreren Ebenen ist bereits möglich. Woher weiß ich, ob der Gegenstand, den ich drag and drop versuche, auf Root-Ebene ist?Check in jQuery Sortierbare Liste, wenn es ein Element auf Root-Ebene ist

Dies ist mein aktueller Code:

$("#koppen_sortable").sortable({ 
      containerSelector: ".sortable-container", 
      itemSelector: ".sortable-item", 
      handle: 'i.fa-arrows', 
      placeholder: '<div class="sortable-item placeholder"> </div>', 
      onDrop: moveKopInDocument, 
      tolerance: 6 
     }); 

// Move the kop with the document 
    var moveKopInDocument = function ($item, container, _super, event) { 
     // Handle move base method first 
     _super($item, container); 

     // here I would like to check if this item current position is a root item or a sub item 
    }; 

Antwort

0

ich es wie folgt festgelegt:

if($item[0].parentElement.parentElement.className !== 'sortable-item') { 
      // this is a root item 
     } else { 
      // this is a sub item 
     } 
Verwandte Themen