vakata / jstree

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

refresh not working #2473

Closed agiorgini closed 3 years ago

agiorgini commented 3 years ago

hello, hope u can help me. I have this setup:

` $('#publication_tree').jstree({ 'core' : { 'data': { 'url': function (node) { return "{{ route('cms.publications.tree', ['rootId' => 1, 'lang'=>'it-IT']) }}"; }, 'data': function (node) { return {'id': node.id}; } }, 'check_callback' : true, },

                'plugins' : [
                    "dnd", "search",
                    //"state", "types", "wholerow"
                ],

                'search': {
                    'case_insensitive': true,
                    'show_only_matches': true
                },

}) `

after successufully adding some data via ajax I try to refresh:

let tree = $('#publication_tree'); tree.jstree(true).refresh(true);

but I get this error: Uncaught TypeError: can't access property "parents", b is undefined

any suggestion?

Thanks a lot

vakata commented 3 years ago

The structure you have is probably broken - duplicate IDs, or disconnected nodes. It depends on what you return as a response to the AJAX calls. Please provide a demo including the data - the problem is most certainly with the data, not jstree itself.