Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sortable] drag nested items with parent "locked" #1996

Open
angel-git opened this issue Oct 19, 2021 · 1 comment
Open

[sortable] drag nested items with parent "locked" #1996

angel-git opened this issue Oct 19, 2021 · 1 comment

Comments

@angel-git
Copy link

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

$( event.target ).closest( this.options.cancel ).length : false );

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

@kghandi
Copy link

kghandi commented Jan 8, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants