实例方法

$.jstree.reference (needle)

get a reference to an existing instance

needleDOMElement jQuery String
ReturnsjsTree the instance or null if not found

Examples

// provided a container with an ID of "tree", and a nested node with an ID of "branch"
// all of there will return the same instance
$.jstree.reference('tree');
$.jstree.reference('#tree');
$.jstree.reference($('#tree'));
$.jstree.reference(document.getElementByID('tree'));
$.jstree.reference('branch');
$.jstree.reference('#branch');
$.jstree.reference($('#branch'));
$.jstree.reference(document.getElementByID('branch'));
$().jstree([arg])

Create an instance, get an instance or invoke a command on a instance.

If there is no instance associated with the current node a new one is created and arg is used to extend $.jstree.defaults for this new instance. There would be no return value (chaining is not broken).

If there is an existing instance and arg is a string the command specified by arg is executed on the instance, with any additional arguments passed to the function. If the function returns a value it will be returned (chaining could break depending on function).

If there is an existing instance and arg is not a string the instance itself is returned (similar to $.jstree.reference).

In any other case - nothing is returned and chaining is not broken.

argString Object
ReturnsMixed

Examples

$('#tree1').jstree(); // creates an instance
$('#tree2').jstree({ plugins : [] }); // create an instance with some options
$('#tree1').jstree('open_node', '#branch_1'); // call a method on an existing instance, passing additional arguments
$('#tree2').jstree(); // get an existing instance (or create an instance)
$('#tree2').jstree(true); // get an existing instance (will not create new instance)
$('#branch_1').jstree().select_node('#branch_1'); // get an instance (using a nested element and call a method)
$(':jstree')

used to find elements containing an instance

ReturnsjQuery

Examples

$('div:jstree').each(function () {
	$(this).jstree('destroy');
});