Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
100
rated 0 times [  106] [ 6]  / answers: 1 / hits: 18675  / 12 Years ago, sat, april 7, 2012, 12:00:00

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/


More From » jquery

 Answers
3

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/checkbox



This is an excerpt from the documentation in the link above, how to perform an operation:



/* METHOD ONE */
jQuery(some-selector-to-container-node-here)
.jstree(operation_name [, argument_1, argument_2, ...]);

/* METHOD TWO */
jQuery.jstree._reference(needle)
/* NEEDLE can be a DOM node or selector for the container or a node within the container */
.operation_name([ argument_1, argument_2, ...]);


So I think this syntax should work



$.jstree._reference(.colors).check_node('li#tree_3');


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:



$.jstree._reference(#colors).check_node('li#tree_3');


//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)


[#86379] Thursday, April 5, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
patienceannel

Total Points: 674
Total Questions: 101
Total Answers: 101

Location: Northern Mariana Islands
Member since Fri, Jan 15, 2021
3 Years ago
patienceannel questions
Fri, Mar 11, 22, 00:00, 2 Years ago
Tue, Oct 20, 20, 00:00, 4 Years ago
Wed, Jul 24, 19, 00:00, 5 Years ago
;