Reputation: 11091
I would like to know how to access jsTree node attributes after the node's checkbox was clicked.
I use $("#jstree").bind('check_node.jstree', function(e, data) {
to trigger my code after the checkbox was clicked.
Now I want to access node's attributes. But I don't know how to use data
object so I can get the attributes. So let's say in my jsfiddle I want to display the value of the attribute along with the text "clicked and checked"
Could you please explain how & why? I am lost how to reference jsTree/jQuery objects.
==== Update
In jsTree data definition node attributes could be defined. I want to programatically check the attributes and then fire different code base on the attributes. In my case "log" attribute.
data = [
{
"data": "Basics",
"attr":{"log":"shared"},
},
{
"data": "All",
"attr":{"log":"bdrs"},
}
]
Upvotes: 3
Views: 5838
Reputation: 100175
you could just do:
$("#jstree").bind('check_node.jstree', function(e, data) {
$("#list").append('<BR>clicked and ' + node_is_check(data));
var node = data.rslt.obj;
console.log( node.attr("log") ); //shows bdrs when All is checked
});
Updated fiddle: jsFiddle Demo
Did you mean something like this
Upvotes: 4