From af50299fb12de9527f84e07b884f49436bec9fad Mon Sep 17 00:00:00 2001 From: kghandi Date: Wed, 8 Jan 2025 15:26:38 -0500 Subject: [PATCH] Allow using a Function as the cancel option instead of a Selector. This is particularly useful when using Sortable on nested lists. --- ui/widgets/mouse.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/widgets/mouse.js b/ui/widgets/mouse.js index ef9dd8dbe9..ce7ce8c749 100644 --- a/ui/widgets/mouse.js +++ b/ui/widgets/mouse.js @@ -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; }