Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with jstree can expand nodes with no children

I'm working with jstree with ajax and I see that all my nodes have the arrow to expand it, even those which have no children. On the demo page of jstree http://www.jstree.com/demo this is not the case. I don't see on the demo code something different from mine, so does it come from the server ? Have I a parameter to put in response of "getChildren" method to say at jstree "this one, have no children, don't enable to expand it"?

Anyone know from where it come from? And what can I do to fix that ?

Because it seems to be a problem when I used the copy / paste function of the contextmenu plugin. When I paste on a node (the new parent) with no children and not yet open (so children haven't been loaded), nothing happen except the request to get children (like if I click to open the node) that return nothing obviously. And it doesn't execute the move_node function.

EDIT : I have the same problem with "add" from the contextmenu

Someone can help me ?

Thanks

like image 839
TiGi Avatar asked Sep 21 '11 12:09

TiGi


1 Answers

From the jsTree documentation:

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

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

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

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

But "open" and "closed" reminded me of node.state, so I tried, and it turned out that when you set node.state to "leaf" in your JSON serialzation class, it will be non-expandable.

like image 138
Stefan Steiger Avatar answered Nov 03 '22 04:11

Stefan Steiger