The documentation at http://getfuelux.com/javascript.html#tree doesn't give good example about how to use Javascript Datasource. I have read a lot of other questions on StackOverflow about it, but most of them are old (still use name
instead of text
). Can anyone help me with the dataSource
and callback
usage?
Here is my current code:
HTML:
<div class="row fuelux">
<div class="col-sm-12">
<div id="grp-tree-hobby">
<ul id="tree-hobbies" class="tree">
</ul>
</div>
</div>
</div>
Javascript:
<script>
$("#tree-hobbies").tree({
dataSource: function (parentData, callback) {
console.log(parentData);
callback({
"data": [
{ "text": "No hobby has been added yet", "type": 'item' },
{ "text": "No hobby has been added yet", "type": 'item' },
],
});
},
});
</script>
None exception is printed in the console, but the ul
is still blank, and if I change ul
into div
, the result was still the same.
Can you please give me an example?