Nestable2-如何防止子节点拖到另一个父节点中? [英] Nestable2- How to prevent child node to dragged in another parent node?

查看:176
本文介绍了Nestable2-如何防止子节点拖到另一个父节点中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,
我使用过nestable2,我想防止子节点不要拖到另一个父节点中节点。

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.

我使用过nestable2的这种方法来获取源和目标。我想验证子节点不应拖到另一个父节点。它应拖入其父级。
我已经应用了以下方法,但是它没有给我destinationtype,请建议帮助

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;
                }
        }
    });


推荐答案

通过在ol中分配类型也解决了该问题。因为我试图将孩子拖到另一个ol列表中,所以我必须输入相同的类型。

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.

这篇关于Nestable2-如何防止子节点拖到另一个父节点中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆