Skip to content

Commit

Permalink
Allow using a Function as the cancel option instead of a Selector. Th…
Browse files Browse the repository at this point in the history
…is is particularly useful when using Sortable on nested lists.
  • Loading branch information
kghandi committed Jan 28, 2025
1 parent b685753 commit af50299
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ui/widgets/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ return $.widget( "ui.mouse", {

var that = this,
btnIsLeft = event.which === 1,
elIsCancel = typeof this.options.cancel === "string" ?
$( event.target ).closest( this.options.cancel ).length :
false;
elIsCancel = typeof this.options.cancel === "function" ?
this.options.cancel.call( event.target, event ) :
( typeof this.options.cancel === "string" ?
$( event.target ).closest( this.options.cancel ).length :
false );
if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
return true;
}
Expand Down

0 comments on commit af50299

Please sign in to comment.