[英]Settings image on demang for jstree client side (without types plugin)
I want to set the image based on leaf title ie if the title of the leaf is test.html
I want the image url to be set to img/html.png
. 我想基于叶子标题设置图像,即如果叶子的标题是test.html
我希望将图像URL设置为img/html.png
。
I want it to be a client-side manipulation only. 我希望它仅是客户端操作。
My question is if there is an event to hook up to before the data is loaded or modified to the tree so I can modify the image url when the node is loading or being updated? 我的问题是在将数据加载或修改到树之前是否有一个事件要挂接到,以便在节点加载或更新时可以修改图像url?
Figured it out (always shortly after asking here for some reason): 弄清楚了(总是出于某种原因在这里询问后不久):
$('#file_tree').jstree().bind('model.jstree', function (event, obj) {
var _tree = return $('#file_tree').jstree(true);
for (var i = 0; i < obj.nodes.length; i++) {
var _node = _tree.get_node(id)
_node.icon = "whatever_icon_path_i_want.png";
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.