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

[sortable] drag nested items with parent "locked"

Open angel-git opened this issue 4 years ago • 1 comments

Is it possible to lock parent elements on the sortable component but leave the children to be sortable?

For instance: https://jsfiddle.net/5mvLfw74/

I would like to sort items 11 and 12 but looks like since the parent is on the cancel selector the whole "tree" is locked.

For what i see the issue might be coming from https://github.com/jquery/jquery-ui/blob/70dae67b73dfea9126f126f516fe8286f1e73417/ui/widgets/mouse.js#L98

Looks like the closest element that matches the cancel selector is the parent and then the mouse event is not triggered

angel-git avatar Oct 19 '21 13:10 angel-git

I had a similar issue to that listed in issue. I have submitted a Pull Request (#2324) to allow cancel option to be a function. This allows me to override the default cancel implementation using a selector with something like:

$('.container', context).sortable({ items: '>.widget', cancel: function (event) { return $(event.target).closest('.widget').is('.locked'); } });

kghandi avatar Jan 08 '25 20:01 kghandi