问题
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