In a tree built with jsTree, I have the text within the <a> tag sitting in a variable. I would like to check that node. How can I do so?
I am currently finding that node, using jQuery, and altering its class. However, this does not repair the parent node by making the parent undetermined in its class. I tried doing $('.colors').jstree("checkbox_repair"), but that didn’t seem to do anything.
It would be great if someone could actually answer both those questions, since they are related to the same problem.
Here is a jsFiddle, illustrating the issue–> http://jsfiddle.net/thapar/5XAjU/
In js_tree there are
.check_node ( node )and.uncheck_node ( node )functions, i think this is what you are asking for. Soe the documentation here: http://www.jstree.com/documentation/checkboxThis is an excerpt from the documentation in the link above, “how to perform an operation”:
So I think this syntax should work
Also i am not sure you should be using a class to reference your tree. Probably use an ID to reference your tree, and then use this syntax:
//EDIT: Please keep in mind that the newest version of jsTree doesn’t have a function called _reference anymore. It got renamed to reference (without the leading underscore). (Last checked 24/08/2015 15:45 by @mkli90)
Link: https://www.jstree.com/api/#/?f=$.jstree.reference(needle)