Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Droppable Node not working #2798

Open
strtob opened this issue Oct 29, 2024 · 0 comments
Open

Droppable Node not working #2798

strtob opened this issue Oct 29, 2024 · 0 comments

Comments

@strtob
Copy link

strtob commented Oct 29, 2024

Hi,

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
                }
            }
        });

Any ideas would be very appreaciated!

Thanks a lot, also for jstree!

Best,
Tobi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant