jsTree从<li>标签</li>中删除文本

时间:2012-05-10 08:14:48

标签: jstree

我第一次尝试jsTree,并且遇到问题,在调用jstree()后,我的<li>元素中的文本消失了。通话结束后,我的树看起来像这样:

<div id="assessment-treeview" class="jstree jstree-0 jstree-focused jstree-classic">
    <ul>
        <li class="jstree-last jstree-open"><ins class="jstree-icon">&nbsp;</ins>
            <ul style="">
                <li class="jstree-last jstree-open"><ins class="jstree-icon">&nbsp;</ins>
                    <ul style="">
                        <li class="jstree-last jstree-leaf"><ins class="jstree-icon">&nbsp;</ins></li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
</div>

在通话之前,它看起来像这样:

<div id="assessment-treeview">
    <ul>
        <li>Specific Outcomes
            <ul>
                <li>[section: name not available for import]
                    <ul>
                        <li>[outcome: name not available for import] </li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
</div>

jstree调用如下所示:

$("#assessment-treeview").jstree({ "themes": { "theme": "classic" } });

导致这种情况的原因是什么?

1 个答案:

答案 0 :(得分:4)

jsTree不喜欢'li'标签内的纯文本节点。当我将项目文本放入像'span'这样的标签时,一切都恢复正常。

从上面的问题代码:

<li><span>Specific Outcomes</span>
    <ul>
    .        
    .       
    </ul>
</li>