AJAX reload checkbox selected state

3,427 views
Skip to first unread message

Wayne Tanner

unread,
Jan 31, 2014, 5:57:57 PM1/31/14
to jst...@googlegroups.com
I have a jstree with the checkbox plugin that I load with JSON data using AJAX. When an event happens in my page, I want to cause the tree to reload and use the selected state that is returned from the AJAX call.
I create my tree as:



$('#jstree').jstree({ 
           "checkbox": { 
                    "keep_selected_style": false 
            }, 
            'core': { 
                     'data': { 
                             'url': function () { return '/home/GetLayerTreeViewData' }, 
                             'data': function (node) { 
                                        return { 'id': node.id }; 
                     }
            } 
    }, 
    "plugins": ["checkbox", "json_data"] 
});

When my event occurs, I refresh the using:
 
("#jstree").jstree(true).refresh();
 
 
My new nodes appear so I know the tree is refreshing and reading the JSON data. I can't get them to appear in an initially checked state however. They will appear selected if I return state selected as true when the tree initially loads, but it seems to be ignored on subsequent loads. I want the tree to ignore whatever state it has and just reload the returned data.  Is there some setting I'm missing or some other parameter I need to pass?
 

 

Ivan Bozhanov

unread,
Jan 31, 2014, 6:39:11 PM1/31/14
to jst...@googlegroups.com
Instead of:
#("#jstree").jstree(true).refresh();

Try using:
("#jstree").jstree(true).load_node('#');

Best regards,
Ivan
Reply all
Reply to author
Forward
0 new messages