A problem with jstree can expand nodes without children

I work with jstree with ajax, and I see that all my nodes have an arrow to expand it, even those that don't have children. On the jstree demo page http://www.jstree.com/demo it is not. I don’t see anything different from mine in the demo code, is that what happens from the server? Do I have a parameter to respond to the getChildren method to say in jstree "this one, you have no children, is not allowed to expand it"?

Does anyone know where he comes from? And what can I do to fix this?

Because it seems to be a problem when I used the copy / paste function of the contextmenu plugin. When I insert on a node (new parent) without children and still do not open (so that the children have not been loaded), nothing happens except for a request for children (for example, if I click to open the node), which return nothing. And it does not execute the move_node function.

EDIT: I have the same problem with β€œadd” from context menu

Can anybody help me?

thanks

+7
source share
4 answers

From the jsTree documentation:

http://www.jstree.com/documentation/html_data 

one of three classes will be applied depending on the node structure:

 <li class="[ jstree-open | jstree-closed | jstree-leaf ]"> 

Jonathan Stowell is right, but setting attr.class to "jstree-leaf" will not work (at least not in the latest version).

But "open" and "closed" reminded me of node.state, so I tried, and it turned out that when you install node. state to a "sheet" in its JSON, it will not expand.

+10
source

I added the jstree-leaf class to the attr property for my nodes that do not have children.

 attr: { "class" : "jstree-leaf" } 

Then a CSS class is defined that does not require an extension function.

+4
source

I had the same problem with the create method and nodes without children. He decided to indicate the state of such nodes as "open" instead of the standard "closed".

Hopes this helps.

+2
source

if you are sending json data give "jstree-leaf" as the li_attr class

  li_attr: {class = "jstree-leaf" } 
+1
source

All Articles