I'm struggling with populating the jquery treeselect widget using a json file or any other method. Since I am new to jquery/javascript, I'm sure I must be missing some basics.
Although I have obtained the plugin from https://github.com/travist/jquery.treeselect.js, I haven't been able to find an example on how to set 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, // not functioning
load: function (node, callback) {
// What should I include here?
/**
* Typically, this would involve calling jQuery.ajax to fetch a new node
* from your server which returns the tree structure for the specified node.
*/
}
});
});
</script>
</head>
<body>
<div class="chosentree"></div>
</body>
</html>