How to change icon in jstree?

后端 未结 10 2183
心在旅途
心在旅途 2021-02-01 16:25

I have the following code:

$(\'.wpFolders.co_files\').bind(\'select_node.jstree\', function (event, data) {
            getFileById(data.args[0].hash.replace(\'#         


        
10条回答
  •  感动是毒
    2021-02-01 16:50

    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'
                }
            },
        });
    

提交回复
热议问题