Me gustaría preguntarle al usuario, eliminar o no eliminar y luego llamar a ajax.
Pero, ¿dónde debería estar el método $.confirm ?
El código anterior se elimina primero para la pantalla del usuario y luego se elimina en el backend.
¿Cómo llamar antes de eliminar el método $.confirm ?
$("#kt_tree_type-make-model").jstree({ "core": { "check_callback": true, "data": data }, "types": { "default": { "icon": "fa fa-folder text-primary" }, "file": { "icon": "fa fa-file text-primary" } }, "contextmenu":{ 'items' : function(node) { var items = $.jstree.defaults.contextmenu.items(); items.create.label = 'ADD'; items.rename.label = 'RENAME'; items.remove.label = 'DELETE'; items.ccp = false; return items; } }, "plugins": ["contextmenu", "state", "types"] }).on('create_node.jstree', function (e, data) { }).on('rename_node.jstree', function (e, data) { }).on('delete_node.jstree', function (e, data) { $.confirm({ type: 'orange', title: 'ARE YOU SURE?', content: 'DELETING.', buttons: { confirm: { text: 'YES, DELETE', action: function () { let node = data.node.id.split('_'); let kind = node[0]; let id = node[1]; $.ajax({ url: `/vehicles/type-make-model/${kind}/delete/${id}`, type: 'get', headers: {'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')}, dataType: 'json', success: function (response) { $.alert({title: false, type: 'green', content: 'Deleted successfully.'}); data.instance.refresh(); }, error: function (xhr, ajaxOptions, thrownError) { $.alert({title: false, type: 'red', content: xhr.responseJSON.message}); data.instance.refresh(); } }); } }, cancel: { text: 'CANCEL' } } }); });