Reputation: 369
I'm new to Bootstrap-treeview (bootstrap-treeview.js v1.0.2). I'm trying to display the tree given in the docs, but it doesn't show up.
I've checked the 2 files, didn't spot the mistake.
html:
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'bootstrap-treeview.min.css' %}">
<title>test</title>
</head>
<body>
<div class="container">
<div id="tree"></div>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-2.1.3.min.js" integrity="sha256-ivk71nXhz9nsyFDoYoGf2sbjrR9ddh+XDkCcfZxjvcM=" crossorigin="anonymous"></script>
<script src="{% static 'bootstrap-treeview.min.js' %}"></script>
<script src="{% static 'functions.js' %}"></script>
</body>
</html>
functions.js
function getTree() {
var tree = [
{
text: "Parent 1",
nodes: [
{
text: "Child 1",
nodes: [
{
text: "Grandchild 1",
},
{
text: "Grandchild 2",
}
]
},
{
text: "Child 2",
}
]
},
{
text: "Parent 2",
}
];
return tree;
}
$('#tree').treeview({data: getTree()});
Upvotes: 1
Views: 1349
Reputation: 908
You are creating array tree
, but returning data
in the getTree
function
Upvotes: 1