vakata / jstree

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

DND plugin not working anymore when destroying jstree and initialing it again #639

Closed saman-ghm closed 10 years ago

saman-ghm commented 10 years ago

I'm initialing the jstree using code below :

   function initTree() {
    $('.tree-container').on("select_node.jstree", function (e, data) {
        var parent = $('.tree-container').jstree('get_selected');
        $('.tree-container').jstree('open_node', parent);
        $(".txt-search-doc").val("");
        getSelectedNodeData(parent.toString());
    }).on('move_node.jstree', function (e, data) {
        moveNode(data);
    }).jstree({
        "search": {
            "case_insensitive": false,
            "show_only_matches": true,
            "fuzzy": false,
            "close_opened_onclear": false
        },
        plugins: ["themes", "search", "contextmenu", "dnd"],
        contextmenu: { items: customMenu },
        "core": {
            "check_callback": true
        }
    });
}

This code works perfectly.I'm making the tree with constant html. For refreshing tree , i'm getting html again and destroy my tree and initial it again :

            $('.tree-container').html(data);
            $(".tree-container").jstree('destroy');
            initTree();

The "data" argument is the html data. After this operation every plugins works great except dnd plugin.the browser shows a javascript error that related to dnd plugin file. Also i shouldn't use ajax and json types for initialing the tree.

vakata commented 10 years ago

This is a duplicate of #621 - simply get the latest code from the repo.