如何格式化“li”和“一” jsTree中的DOM元素通过设置它们的类?
基本上,我有一个 jsTree,我需要通过添加自定义类来格式化它的 li 和 a DOM 元素到每种类型。文档不清楚如何执行此操作,据我所知,无法添加自定义类,任何格式都必须通过覆盖 jquery 主题或编辑 jsTree 源代码来实现。我可以在 JSON 数据中执行此操作,或者在声明“类型”时更有效地执行此操作,如下例所示:
$("#container").jstree({
"plugins" : ["themes", "json_data", "ui", "themeroller", "types"],
"json_data" : {"data": my_json_data},
"core" : {
"initially_select" : [ init_id]
},
"types" : {
"valid_children" : [ "test_type" ],
"types" : {
"test_type" : {
"valid_children" : [ "default", "test_type" ],
"icon" : { "image" : "/includes/icon.gif"}
}
}
},
"themes" : {
"dots" : true,
"icons" : true
}
});
Basically, I have a jsTree, and I need to format it's li and a DOM elements by adding custom class to each type. The documentation is not clear on how to do this and as far as I can tell, there is no way to add custom class, any formating will have to be by overriding jquery theme or by editng the jsTree source-code. I am ok with either doing it in the JSON data, or more effectively, when declaring the "types" as shown in the example here:
$("#container").jstree({
"plugins" : ["themes", "json_data", "ui", "themeroller", "types"],
"json_data" : {"data": my_json_data},
"core" : {
"initially_select" : [ init_id]
},
"types" : {
"valid_children" : [ "test_type" ],
"types" : {
"test_type" : {
"valid_children" : [ "default", "test_type" ],
"icon" : { "image" : "/includes/icon.gif"}
}
}
},
"themes" : {
"dots" : true,
"icons" : true
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想在 JSON 响应中执行此操作,这对我有用:
第一个 attr 引用
标记,第二个 attr< /strong>(内部数据)指的是
标签。
If you want to do it in the JSON response, this works for me:
The first attr refers to the
<li>
tag, and the second attr (inside data) refers to the<a>
tag.