jquery-sortable
jquery-sortable copied to clipboard
If another list number is full, how to limit the move to it and trigger function?
For example, there are three ul, each UL can only have 10 li. If you drag onto the maximum number of regions, it will be fail and trigger function nextpage();
#1:<ul><li></li><li></li><li></li></ul>
#2:<ul><li></li><li></li><li></li>.....10 li....</ul>
#3:<ul><li></li><li></li><li></li></ul>
#1 or #3 cannot drag to #2 .
If #2 has been moving to #1, #1 reached 10, #2 can no longer move to #1
What should I do to achieve this effect? Thank you!
Translated from https://github.com/johnny/jquery-sortable/issues/213
isValidTarget: function ($item, container){
var depth = 1;
var maxDepth = 2;
var children = $item.find('ol').first().find('li');
//Add the amount of parents to the depth
depth += container.el.parents('ol').length;
//Increment the depth for each time a child
while (children.length) {
depth++;
children = children.find('ol').first().find('li');
}
return depth <= maxDepth
},