vakata / jstree

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

get id of of parent node when dropped #2779

Closed kpetrow closed 5 months ago

kpetrow commented 5 months ago

Currently when i get the id of the node on the DND_stop event it still ahs the old parent id. Where do i get the new parent id?

kpetrow commented 5 months ago

sorta of hacky workaround that can give you the sibling instead of the target

FLEET_EXPLORER_JSTREE.get_node(data.event.target);

then loop through item and parents until you hit the type? that you are looking through;

if (newFleetId.type == 'myType') {
        newFleetId = newFleetId.id
    } else {
        for (var i = 0; i < newFleetId.parents.length; i++) {
            var temp = FLEET_EXPLORER_JSTREE.get_node(newFleetId.parents[i]);
            if (temp.type == 'myType') {
                newFleetId = temp.id;
                break;
            }
        }
    };
kpetrow commented 5 months ago

figured it out. move_node event although this seems like on drag but not image