RamonSmit / Nestable2

New pickup of Nestable!
Other
322 stars 147 forks source link

How to prevent child node to dragged in another parent node #117

Open bugfirstx opened 2 years ago

bugfirstx commented 2 years ago

xZAfn (1)

Thank you

b-cil commented 2 years ago

prevent child to go parent and parent to go child, my guess is that you have just to play with parent id to get what you want on top

beforeDragStop: function(l,e, p){ // l is the main container // e is the element that was moved // p is the place where element was moved. m_element = $(e).data('type'); t_element = $(p).hasClass('nestable');

    if(m_element == "child"){
      if (t_element){
        return false;
      }else{
        return true;
      }
    }else if (m_element == "root"){
      if (t_element){
        return true;
      }else{
        return false;
      }
    }
}