knockout-sortable icon indicating copy to clipboard operation
knockout-sortable copied to clipboard

Confirmation popup before aftermove is executed

Open mrshawn191 opened this issue 7 years ago • 1 comments
trafficstars

Hi I have this piece of code

			<div class="query-result" data-bind="onWindowResize: 218">
				<ul class="nav nav-pills nav-stacked" data-bind="sortable: { template: 'query-result-item-template', aftermove: reorder, data: $page.child('read')().children }">
				</ul>
			</div>

Its a list, and everytime you move each item a function reorder is executed.

My question is it possible to add a confirmation popup before the reorder function is executed? I want to warn the user about the action he is going to perform.

mrshawn191 avatar May 09 '18 16:05 mrshawn191

You can use the beforeMove handler and set arg.cancelDrop to true if the user wishes to cancel the move.

ko.bindingHandlers.sortable.afterMove = function (arg, event, ui) {
  //show popup, get user response, set arg.cancelDrop accordingly
}

derrickb avatar Jul 08 '18 14:07 derrickb