简体   繁体   English

jsTree图标未出现

[英]jsTree icons not appearing

I have a jsTree. 我有一个jsTree。 The tree is rendering correctly and I am getting a whole bunch of nodes that look like this: 这棵树正确渲染,我得到了一堆看起来像这样的节点:

<li 
    id="aaaa" 
    data-level="2" 
    data-wiid="bbbb" 
    data-itemid="aaaa" 
    data-witype="Tasks" 
    class="jstree-leaf">

        <ins class="jstree-icon">&nbsp;</ins>
        <a href="#" class="">
            <ins class="jstree-icon">&nbsp;</ins>
            Some Node Text
        </a>
</li>

I'm trying to set the icons of the nodes: 我正在尝试设置节点的图标:

$('#jsTreeDiv').jstree({ 
    'json_data'     : {'data': preloadedData}, 
    'plugins'       : ['themes', 'json_data', 'ui', 'contextmenu', 'types'],
    'types'         : {
                        'type_attr' : 'data-witype',
                        'types'     : 
                        {
                            'Tasks' : {'icon': { 'image': '/imgs/tasks.png' }
                        }
                      });

This doesn't seem to be working. 这似乎不起作用。 Icons aren't being set for my jsTree. 没有为我的jsTree设置图标。 When I check the Sources tab in chrome's developer tools it doesn't even appear to be loading the images. 当我在chrome的开发人员工具中检查“来源”标签时,它甚至似乎都没有加载图像。

Can anyone see where I'm going wrong? 谁能看到我要去哪里错了?


Update 更新

I've found that the icons are actually being loaded, but they're being set to hidden in css 我发现图标实际上已被加载,但是它们被设置为隐藏在CSS中

.jstree-default a ins.jstree-icon {
    display: none;
}

If I toggle this style in the developer tools I get the icons appearing. 如果在开发人员工具中切换此样式,则会显示图标。 I must be missing a setting or something. 我一定缺少设置或其他东西。

Anyone have any ideas? 有人有想法么?


Update 更新

I'm limited to using jsTree 1.0-rc3 我仅限于使用jsTree 1.0-rc3

I believe you are using the old version of jsTree. 我相信您正在使用旧版本的jsTree。 I recommend getting the latest version and adapting your code to it's new syntax. 我建议获取最新版本,并使代码适应新的语法。 I managed to get it working very quickly by following it's documentation. 通过遵循文档,我设法使其快速运行。

Here's the working example: http://jsfiddle.net/bortao/SJgLJ/ 这是工作示例: http : //jsfiddle.net/bortao/SJgLJ/

You need to change the type defintion: 您需要更改类型定义:

JS JS

'types': {
    'Tasks': {
        'icon': 'iconfile.png'
    }
}

HTML HTML

<li data-jstree='{"type":"Tasks"}'> </li>

I eventually solved this by updating the CSS. 我最终通过更新CSS解决了这个问题。 The styles.css file has a section marked like this: styles.css文件的一部分标记如下:

/* IE6 BEGIN */
.jstree-default li, 
.jstree-default ins,
#vakata-dragged.jstree-default .jstree-invalid, 
#vakata-dragged.jstree-default .jstree-ok, 
#jstree-marker.jstree-default { _background-image:url("d.gif"); }
.jstree-default .jstree-open ins { _background-position:-72px 0; }
.jstree-default .jstree-closed ins { _background-position:-54px 0; }
.jstree-default .jstree-leaf ins { _background-position:-36px 0; }
.jstree-default a ins.jstree-icon { _background-position:-56px -19px; }
#vakata-contextmenu.jstree-default-context ins { _display:none; }
#vakata-contextmenu.jstree-default-context li { _zoom:1; }
.jstree-default .jstree-undetermined a .jstree-checkbox { _background-position:-20px -19px; }
.jstree-default .jstree-checked a .jstree-checkbox { _background-position:-38px -19px; }
.jstree-default .jstree-unchecked a .jstree-checkbox { _background-position:-2px -19px; }
/* IE6 END */

By commenting out this entire section of CSS, the images started appearing as expected. 通过注释掉CSS的整个部分,图像开始按预期显示。

I am constrained to an old version of jsTree, but at least I don't have to support IE6! 我受制于jsTree的旧版本,但至少我不必支持IE6!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM