Closed pszNicx closed 5 years ago
I figured out the issue. I was trying to process the tree in my JQuery ready block but that's before the treeview initializes. Example:
$(function() {
$('#treeview').treeview({ levels: 3, highlightSelected: false, data: [
{text: 'foo', id: 1, category: 'a', nodes: [
{text: 'bar', id: 2, category: 'b', nodes: [
{text: 'bla', id: 4, category: 'c', nodes: []}
]},
{text: 'baz', id: 3, category: 'b', nodes: []}
]}
] });
var tree = $('#treeview').treeview(true);
var categoryNodes = tree.findNodes('b', 'category'); // <-- Throws Cannot read property 'length' error
});
To fix, I just needed to move my logic until after everything initializes.
Hi,
I've been running into an issue with unallocated nodes causing a few of the calls to not work properly. I'm not sure if I'm not doing something right but I worked around the issue by editing the bootstrap-treeview.js file.
My version of bootstrap-treeview.js says v2.1.0 at the top but I think it's actually 2.1.8 since I downloaded the latest. My jQuery is version 3.4.1 and Bootstrap is 3.3.7.
Even with a very simple data load it seems to have issues with finding/expanding/collapsing select nodes. When I debugged it I found the issue occurring at the
$.grep
call on line 1886 of bootstrap-treeview.js, where the value ofthis._orderedNodes
(andthis._nodes
) are null.I worked around my particular issue by adding the following just before that line:
Am I missing some initialization step or is there something actually broken here?