javascript - 在 jsTree 的上下文菜单中创建功能不起作用
问题描述
定义“类型”插件时不会创建新节点。
请看这个小提琴。我无法在树中创建新节点。 http://jsfiddle.net/z8L5r9w3/1/
$('#jstree').jstree({
"core" : {
"check_callback" : true,
"data" : [
{ "text" : "Branch 1", "type" : "branch", "children" : [
{ "text" : "leaf 1.1", "type" : "leaf" },
{ "text" : "leaf 1.2", "type" : "leaf" },
{ "text" : "leaf 1.3", "type" : "leaf" }
]
},
{ "text" : "Branch 2", "type" : "branch", "children" : [
{ "text" : "leaf 2.1", "type" : "leaf" },
{ "text" : "leaf 2.2", "type" : "leaf" },
{ "text" : "leaf 2.3", "type" : "leaf" }
]
}
]
},
"types" : {
"#" : {
"valid_children" : ["branch"]
},
"branch" : {
"valid_children" : ["leaf"]
},
"leaf" : {
"valid_children" : []
}
},
"plugins" : ["types", "dnd", "contextmenu"]});
解决方案
您对“类型”有疑问。“上下文菜单”中的“创建”操作不知道“分支”和“叶子”的类型,并使用“类型”创建新节点:“默认”。你可以看到这个:
"types" : {
"#" : {
"valid_children" : ["branch", "default"]
},
"branch" : {
"valid_children" : ["leaf", "default"]
},
"leaf" : {
"valid_children" : []
}
},
推荐阅读
- mysql - 我无法让我的查询从我的产品表中提取所有记录
- c++ - C++字节数组到int
- python - 如何将frozendict对象转换为熊猫数据框
- javascript - 如何查看 RecyclerView 项目逆序最新项目在顶部
- c# - 如何在 C# 控制台应用程序中使用扩展 ascii 字符
- spring-boot - Spring Boot、H2 和 Flyway:使用两个版本的数据库运行集成测试
- maven - 如何将 Maven 项目模块中的所有依赖项复制到目录中?
- jquery - 控制器将微软图表作为图像返回给 AJAX 调用
- c# - QuickFixN 不发送交易时段的登录信息
- c# - 在 C#.Net 中将文件上传到 zoho 联系人