vakata / jstree

jquery tree plugin
http://jstree.com
MIT License
5.13k stars 1.39k forks source link

Cannot read property 'dots' of undefined error in jstree #1895

Closed turjachaudhuri closed 6 years ago

turjachaudhuri commented 6 years ago

JSCode

$('#jstree_demo_div_1').jstree({ 'core' : jsonInputJSTree });

HTML

a div defined with id="jstree_demo_div

jsonInputJSTree is a json string with following value

{"data":[{"id":"1","parent":"#","text":"aws-glue/source-files/excel-source-files/"},{"id":"2","parent":"1","text":"aws-glue/source-files/excel-source-files/deal-mapping/"},{"id":"3","parent":"2","text":"aws-glue/source-files/excel-source-files/deal-mapping/Deal name.xlsx"},{"id":"4","parent":"1","text":"aws-glue/source-files/excel-source-files/kpop-offshore/"},{"id":"5","parent":"4","text":"aws-glue/source-files/excel-source-files/kpop-offshore/KPOP Offshore_Q2 2017.xlsx"},{"id":"6","parent":"4","text":"aws-glue/source-files/excel-source-files/kpop-offshore/KPOPOffshoreTrial_Q3 2017.xlsx"},{"id":"7","parent":"4","text":"aws-glue/source-files/excel-source-files/kpop-offshore/copy_KPOP Offshore_Q2 2017.xlsx"},{"id":"8","parent":"4","text":"aws-glue/source-files/excel-source-files/kpop-offshore/turja-kpop-offshore_Q3 2017.xlsx"},{"id":"9","parent":"1","text":"aws-glue/source-files/excel-source-files/pias-data-pull-MH/"},{"id":"10","parent":"9","text":"aws-glue/source-files/excel-source-files/pias-data-pull-MH/MH_PIAS Data Pull_Q3 2017.xlsx"},{"id":"11","parent":"1","text":"aws-glue/source-files/excel-source-files/pias-data-pull/"},{"id":"12","parent":"11","text":"aws-glue/source-files/excel-source-files/pias-data-pull/PIAS Data Pull_Q3 2017.xlsx"}]}

When i hardcode this string in data section of jstree it works perfectly , but when i use variable , it does not.

turjachaudhuri commented 6 years ago

same json when hardcoded in the jstree definition works , but not when i derive it using JSON.stringify.

vakata commented 6 years ago

Please read the docs on what jstree expects in the data parameter. There are plenty of demos as well, JSON.stringify has no place when passing in data.