0
votes

I instantiate my tree

$('#my-tree').jstree({
        "core": {
            "data": data,
            "themes": {
                "dots": false,
                "icons": false
            }
        },
        "checkbox": {
            "three_state": false,
            "keep_selected_style": true
        },
        "plugins": ["wholerow", "checkbox"]
    });

but when I attempt to get a node on button click, like so:

var node = $("#my-tree").jstree(true).get_node("3", 'true');

It fails with the error:

.get_node is not a function

If I instantiate the tree again like so:

$("#my-tree").jstree()

It works.

Any ideas about what's going on?

I'm using partial views in ASP.NET and the JS is in its own JS file.

One other problem is, that I have to include the library in both the main cshtml file as well as the partial, otherwise, it throws similar errors saying jstree is not a function

<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.12/jstree.min.js" ></script>