jquery-sortable icon indicating copy to clipboard operation
jquery-sortable copied to clipboard

If another list number is full, how to limit the move to it and trigger function?

Open amhoho opened this issue 9 years ago • 1 comments

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!

amhoho avatar Dec 27 '16 17:12 amhoho

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
            },

spidfire avatar Aug 20 '18 13:08 spidfire