I have jstree populated with this code:
jQuery(function($) {
var treesList = {!trees};
for(j=0; j<treesList.length; j++) {
console.log(treesList[j]);
$("#jstree"+treesList[j].attr.promotion_item).jstree({ // here we define the tree structure
"core" : { "animation" : 200 },
"json_data" : { "data" : treesList[j]},
"themes" : {"dots" : false, "theme" : "classic"},
"types" : { "types" : {
"default" : { "icon" : { "image" : null } },
} },
"plugins" : [ "themes", "json_data" , "types"]
});
}
rerenderTable();
});
I want to set the href attribute for the json_data If I print the treesList element, I get that data has a title but not an href attribute.
How can I add it with js in order for jstree to view it and populate it in the generated li element? I've tried with:
treesList[j].data.attr = "";
treesList[j].data.attr.href = "link";
but I get an undefined value.
This is what I have:
Object { title="Iphone3S"}
What I got:
Object { title="Iphone3S", attr=""}
What I think I need to makethe jstree link to work
Object { title="Iphone3S", attr= {href="link"}}
Thanks.
There are many error, like:
treesList[j].data.attr = "";
treesList[j].data.attr.href = "link";
should be:
treesList[j].data.attr = {};
treesList[j].data.attr.href = "link";
and the following is a syntax error:
Object { title="Iphone3S", attr= {href="link"}}
should be:
Object { title="Iphone3S", attr: {href : "link"}}
尝试这个,
treesList[j].data.attr= {href:"link"};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.