vakata / jstree

jquery tree plugin
http://jstree.com
MIT License
5.14k stars 1.38k forks source link

Show Confirmation dialog before delete in Jstree #2538

Closed sudheeryadav013 closed 3 years ago

sudheeryadav013 commented 3 years ago

Is there any way to show confirmation before deleting of node, I tried adding in check_callback but I am showing confirm dialog box using Sweetalert 2 which use promise for the result, so it gets value before even get confirm from sweetalert, Is there any way I can stop from assigning value to check_callback before getting confirm from sweetalert.

"check_callback": function (operation, node, node_parent, node_position, more) { debugger if (operation === 'delete_node') { alertMessageDelete(function (result) { debugger if (result.value == true) { return true } else { return false; } }); } return true; },

vakata commented 3 years ago

The easier way would be to bind the alert to your UI and only invoke jstree's delete method once the user has confirmed. This will not work with the default keyboard shortcuts out of the box though - you would have to override the 'del' shortcut to first show the alert. Same goes for the contexmenu (if you use it) delete action.