I've searched for hours, but I can't find a solution, to drop a div on a node do not work:
$(".jstree-node")
.droppable({
//accept: '.filemanager-file-row', // Accept file rows
//hoverClass: "tree-hover",
drop: function (event, ui) {
// Ensure jstree is properly initialized
var jstreeInstance = $(this).jstree(true);
var selectedNodes = jstreeInstance.get_selected(true); // Get selected nodes
console.log(selectedNodes);
if (selectedNodes.length > 0) {
var categoryId = selectedNodes[0].id; // Get the category ID
var fileId = ui.helper.data('key'); // Get the file ID
// Perform AJAX call to move file
$.ajax({
url: '/filemanager/category/move',
type: 'POST',
data: {
category_id: categoryId,
file_ids: [fileId] // Pass as an array
},
success: function () {
$.pjax.reload({ container: '#pjax-container-file' }); // Reload the grid
alert('File moved successfully!');
},
error: function () {
alert('An error occurred while moving the file.');
}
});
} else {
alert('Please select a category to move the file into.'); // Alert if no category is selected
}
}
});
Hi,
I've searched for hours, but I can't find a solution, to drop a div on a node do not work:
Any ideas would be very appreaciated!
Thanks a lot, also for jstree!
Best, Tobi