I have the following code:
$(\'.wpFolders.co_files\').bind(\'select_node.jstree\', function (event, data) {
getFileById(data.args[0].hash.replace(\'#
After trying so many configurations unsuccessfully, I found a great idea!
By using online photo editor https://pixlr.com/editor/ I have opened icon image file under the path:
jstree\themes\default\32px.png
And I opened the folder icon I want to replace
Replace it easily and save :) I think it is the best after 2 hour struggle.
I was able to replace several icons using the following CSS, without using the Types plugin. Hopefully this helps someone else as well!
/* replace folder icons with another image, remove leaf image */
li.jstree-open > a .jstree-icon {background:url("imageOpen.gif") 0px 0px no-repeat !important;}
li.jstree-closed > a .jstree-icon {background:url("imageClosed.gif") 0px 0px no-repeat !important;}
li.jstree-leaf > a .jstree-icon { display: none; }
/* replace checkbox icons */
li.jstree-unchecked > a .jstree-checkbox, li.jstree-undetermined > a .jstree-checkbox
{
background:url("uncheckedImage.png") 0px 0px no-repeat !important;
width: 32px;
height: 29px;
padding-top: 5px;
}
li.jstree-checked > a .jstree-checkbox
{
background:url("checkedImage.png") 0px 0px no-repeat !important;
width: 32px;
height: 29px;
padding-top: 5px;
}
The way to change icon based on the level:
jQuery('#tree-edit').on('changed.jstree', function(e, data) {
//do something
}).on("open_node.jstree", function(event, data) {
jQuery.each(data.instance._model.data, function(key, val) {
console.log(key + ", " + val);
if (key.length < 4 || key=='#') {
jQuery.jstree.reference("#tree-edit").set_type(val, "selectable");
}
});
}).on("loaded_node.jstree", function(event, data) {
console.log(data);
}).jstree({
'plugins': ["search", "types"],
'core': {
'data': {
'url': 'http://www.google.com/json',
'data': function(node) {
return {'id': node.id};
}
}
},
'types': {
'selectable': {
'icon': 'http://elpidio.tools4software.com/images/icon-ok-small.png'
},
'default': {
'icon': 'http://www.fabulatech.com/printer-for-remote-desktop-server-help/img/icons/warning-small.gif'
}
},
});
try this code:
lst_item = [];
$('#city_tree li').each(function(){ lst_item.push($(this).attr('id')); });
$('#city_tree').jstree(true).set_icon(lst_item, "/static/global/plugins/jstree/province.png");