-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Allow using a Function as the cancel option instead of a Selector. #2324
base: main
Are you sure you want to change the base?
Allow using a Function as the cancel option instead of a Selector. #2324
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. This change makes sense to me, although before formally accepting I'd like @fnagel to also voice his opinion for possible wider context.
If Felix agrees this makes sense, there are still a number of changes we need before accepting this PR:
- Make sure you follow our style guide: https://contribute.jquery.org/style-guide/js/. Currently, indentation is wrong, it uses spaces instead of tabs, spaces are missing inside of parens, etc.
- Connected to the above - make sure our tests & linters succeed on the code before asking for another review. In this case, ESLint fails, for example. Run
npm install && npm run build && npm run lint && npm test
locally and see if everything works. - This change needs tests in all affected modules: draggable, sortable, etc. - perhaps whatever depends on
$.ui.mouse
. - This needs API updates so we'll need a PR to https://github.com/jquery/api.jqueryui.com/ as well before merging any new API.
Sounds reasonable to me and the changes are not that big, so I'm fine with integrating this when all requirements are met. |
…is is particularly useful when using Sortable on nested lists.
05feb2a
to
af50299
Compare
I have fixed the code style as requested. I have also created pull request for api documentation jquery/api.jqueryui.com#369 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates and the API PR. We still need to get this point addressed:
This change needs tests in all affected modules: draggable, sortable, etc. - perhaps whatever depends on
$.ui.mouse
.
It's very important to have all new features covered by extensive tests.
This is particularly useful when using Sortable on nested lists.
I had a similar issue to that listed in issue #1996. Allowing cancel option to be a function 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');
}
});