jstree 的问题可以扩展没有子节点的节点
我正在使用 jstree 和 ajax 进行工作,我发现我的所有节点都有展开它的箭头,即使是那些没有子节点的节点。在 jstree http://www.jstree.com/demo 的演示页面上,情况并非如此。我在演示代码中没有看到与我的不同的东西,那么它来自服务器吗?我是否有一个参数来响应“getChildren”方法,在 jstree 上说“这个,没有孩子,不能扩展它”?
有谁知道它是从哪里来的吗?我能做些什么来解决这个问题?
因为当我使用contextmenu插件的复制/粘贴功能时,这似乎是一个问题。当我粘贴到没有子节点且尚未打开(因此子节点尚未加载)的节点(新父节点)时,除了获取子节点的请求(就像我单击打开节点)明显不返回任何内容之外,没有任何反应。并且它不执行 move_node 函数。
编辑:我对上下文菜单中的“添加”有同样的问题
有人可以帮助我吗?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
来自 jsTree 文档:
将根据节点结构应用三个类之一:
Jonathan Stowell 是对的,但将 attr.class 设置为“jstree-leaf”将不起作用(至少在最新版本上不起作用)。
但是“open”和“close”让我想起了node.state,所以我尝试了一下,结果发现当你在JSON序列化类中将node.state设置为“leaf”时,它将是不可扩展。
From the jsTree documentation:
one of the three classes will be applied depending on node structure :
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.
我将 jstree-leaf 类添加到没有子节点的 attr 属性中。
然后,这将设置您需要的 CSS 类,使其不具有扩展功能。
I added the
jstree-leaf
class to theattr
property for my nodes that do not have children.This then sets the CSS class you need to not have the expand feature.
我对“创建”方法和没有子节点的节点也有同样的问题。解决了将此类节点的状态指定为“打开”而不是默认的“关闭”的问题。
希望这有帮助。
I had the same problem with "create" method and nodes without children. Solved it specifying such nodes' state as "open" instead of the default "closed".
Hopes this helps.
如果发送 json 数据,请将“jstree-leaf”作为 li_attr 的类
if you send json data, give "jstree-leaf" as li_attr's class
返回 JSON 对象时,如果该节点没有子节点,请将
children
属性设置为false
并将state
属性设置为假。
When you return the JSON object, if the node does not have children, set the
children
property tofalse
and set thestate
property tofalse
.