首页 > 解决方案 > 如何编辑 Jstree 输入文本?

问题描述

我可以使用 Metronic Theme 并且我有这样的课程

       <div class="pb-5" data-wizard-type="step-content">
                                        <div id="kt_tree_2" class="tree-demo">
                                            <ul>
                                                <li>
                                                 Root node 1
                                                    <ul>
                                                        <li  data-jstree='{ "icon" : "flaticon2-analytics text-success " }'>

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

                                                </li>
                                            </ul>
                                        </div>
                                    </div>

当我在我的主题中写文字时不会显示它。我更改了根节点 1 文本。

Metronic 树示例

我怎样才能访问输入?JS树


        this._data.core.original_container_html = this.element.find(" > ul > li").clone(true);
            this._data.core.original_container_html
                .find("li").addBack()
                .contents().filter(function() {
                    return this.nodeType === 3 && (!this.nodeValue || /^\s+$/.test(this.nodeValue));
                })
                .remove();
            this.element.html("<"+"ul class='jstree-container-ul jstree-children' role='group'><"+"li id='j"+this._id+"_loading' class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='none'><i class='jstree-icon jstree-ocl'></i><"+"a class='jstree-anchor' role='treeitem' href='#'><i class='jstree-icon jstree-themeicon-hidden'></i>" + this.get_string("Loading ...") + "</a></li></ul>");
            this.element.attr('aria-activedescendant','j' + this._id + '_loading');
            this._data.core.li_height = this.get_container_ul().children("li").first().outerHeight() || 24;
            this._data.core.node = this._create_prototype_node();


_create_prototype_node : function () {
            var _node = document.createElement('LI'), _temp1, _temp2;
            _node.setAttribute('role', 'none');
            _temp1 = document.createElement('I');
            _temp1.className = 'jstree-icon jstree-ocl';
            _temp1.setAttribute('role', 'presentation');
            _node.appendChild(_temp1);
            _temp1 = document.createElement('A');
            _temp1.className = 'jstree-anchor';
            _temp1.setAttribute('href','#');
            _temp1.setAttribute('tabindex','-1');
            _temp1.setAttribute('role', 'treeitem');
            _temp2 = document.createElement('I');
            _temp2.className = 'jstree-icon jstree-themeicon';
            _temp2.setAttribute('role', 'presentation');
            _temp1.appendChild(_temp2);
            _node.appendChild(_temp1);
            _temp1 = _temp2 = null;

            return _node;
        },

我尝试手动 li 和 i 标签。如果我创建 li 并且 i 在此 div 图标内不显示。我只看到文件夹图标。其实我不需要动态。

标签: javascriptjqueryjstree

解决方案


推荐阅读