I'm trying to get the name of the clicked node from
jstree
I'm not good in ajax I'm trying this way that I found but is not working, and i don't know from where the problem come
folderTreeView = $(".folderpreview");
var datanew = JSON.parse(data)
// Files Treeview
if (folderTreeView.length) {
folderTreeView.jstree({
core: {
themes: {
dots: false,
},
data: datanew.children,
},
plugins: ["types"],
types: {
default: {
icon: "far fa-folder font-medium-1",
},
".jpg": {
icon: "far fa-file-image text-info font-medium-1",
},
".docx": {
icon: "far fa-file-word text-info font-medium-1",
},
".pdf": {
icon: "far fa-file-pdf text-info font-medium-1",
},
},
});
folderTreeView
.on("changed.jstree", function (e, data) {
var i, j, r = [];
for (i = 0, j = data.selected.length; i < j; i++) {
r.push(data.instance.get_node(data.selected[i]).name);
}
$("#event_result").html("Selected: " + r.join(", "));
})
.jstree({
core: {
data: {
url: function (node) {
return node.id === "#" ? "./ajax_roots.json" : "./ajax_children.json";
},
data: function (node) {
return { 'id' : node.id};
},
},
},
});
}