FAQ

Some setting (opened, selected) does not work properly, tree is not behaving properly.

USE VALID IDs: ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

If you use periods (".") in your IDs keep in mind jsTree deals with jquery selectors. So an ID like this: my.id, would become "#my\\.id" if passed as "selected".

When moving or creating node “inside” another node, the callback REF_NODE does not point to the new parent node. What to do?

This is not a bug! Because you can create nodes at a specific position among the parent node’s children, passing only the parent node will not be enough. This is why you must always check the TYPE argument passed to the callbacks! If you want to always work with the parent node – add this line at the top of the callbacks:

...
if(TYPE != "inside") { 
  TYPE="inside"; 
  REF_NODE = $(NODE).parents("li:eq(0)").get(0); 
}
...

I am using an XML file as data source, but I get a blank tree.

First of all – make sure you are running your files on a web server and not from the local file system (the address you see in the browser should not begin with ‘file://’).
As for the error – check the headers the server returns for the file you request. Any XML file should be preceded by a ‘text/xml’ header.

I am using predefined HTML and would like the links to work.

Use the onchange callback like this:

...
onchange : function (NODE) {
  document.location.href = $(NODE).children("a:eq(0)").attr("href");
}
...

You could also change any frame, or just load the contents.
Note – if you are using the cookie functionality – check if this is the first time this page loads. Otherwise as the page loads, the script selects the last selected node and leads to another refresh of the same page – endless cycle. Try this:

...
onchange : function (NODE) {
  if(!first) {
    first = true;
    return;
  }
  document.location.href = $(NODE).children("a:eq(0)").attr("href");
}
...