Nestable2- How to prevent child node to dragged in another parent node?

ぃ、小莉子 提交于 2020-07-10 07:00:01

问题


Hello, I have used nestable2, I want to prevent child node not to dragged in another parent node. It should be dragged in its parent node only.

I have used this method of nestable2 to get source and destination. I want to put validation that child node should not dragged to another parent. it should dragged in its parent. I have applied below method, but it is not giving me destinationtype, Please suggest help

  $('#nestable').nestable({
        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.
                var sourcetype = $(e).data('type');//field
                var destinationtype = $(p).data('type');//field
                var sourcegroupid = $(e).data('groupid');//5
                var destinationgroupid = $(p).data('groupid');//5
                if (sourcetype == 'field' && destinationtype == 'field') {

                    if (sourcegroupid == destinationgroupid)//suppose 5=5
                        return true;
                    else
                        return false;
                }
        }
    });

回答1:


Solved the problem by assigning type in ol too. Because i was trying to drag child to another ol list so i have to give same type.



来源:https://stackoverflow.com/questions/62636340/nestable2-how-to-prevent-child-node-to-dragged-in-another-parent-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!