I am having trouble with populating this jquery treeselect widget with a json file (or anything) I am new to jquery/javascript so I am probably missing some fundamentals.
I have the plugin from https://github.com/travist/jquery.treeselect.js and have found no example of how to load it up.
<html>
<head>
<script type='text/javascript' src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.js"></script>
<script type='text/javascript' src='js/jquery.moreorless.js'></script>
<script type='text/javascript' src='js/jquery.treeselect.js'></script>
<script type='text/javascript' src='js/jquery.chosentree.js'></script>
<link rel='stylesheet' type='text/css' href='css/moreorless.css'/>
<link rel='stylesheet' type='text/css' href='css/treeselect.css'/>
<link rel='stylesheet' type='text/css' href='css/chosen.css'/>
<script type='text/javascript'>
jQuery(function () {
var data1 = ["EVENT1", "EVENT2"];
var data2 = [{
"id": 1,
"name": "A green door"
},
{
"id": 2,
"name": "A blue door"
}
]
$('div.chosentree').chosentree({
width: 200,
deepLoad: true,
default_value: data2, // does not work
load: function (node, callback) {
// What do I put here?
/**
* This would typically call jQuery.ajax to load a new node
* on your server where you would return the tree structure
* for the provided node.
*/
}
});
});
</script>
</head>
<body>
<div class="chosentree"></div>
</body>
</html>