Andreu Ramos
Andreu Ramos

Reputation: 2908

Jstree not rendering properly

i did a descendant tree for an entity in my app, using the libray jstree. I do what is usual to use it:

I'm sorry but i can't provide you my source code because is dynamically generated from diferent parts of the app, but i can show a result example of the <ul>&<li> structure:

<div id="unidadtree">
<ul>
    <li id=182 ><a href="-censored-">Node-name</a></li>
    <li id=170 ><a href="-censored-">Node2-name</a>
        <ul>
            <li id=179 ><a href="-censored-">Node2.1-name</a></li>
            <li id=171 ><a href="-censored-">Node2.2-name</a>
                <ul>
                    <li id=172 ><a href="-consored-">Node2.2.1-name</a></li>
                </ul>
            </li>
            <li id=176 ><a href="-censored-">Node2.3-name</a>
                <ul>
                    <li id=178 ><a href="-censored-">Node2.3.1-name</a></li>
                    <li id=177 ><a href="-censored-">Node2.3.2-name</a></li>
                </ul>
            </li>
            <li id=175 ><a href="-censored-">Node2.4-name</a>
                <ul>
                    <li id=33 ><a href="-censored-">Node2.4.1-name</a>
                        <ul>
                            <li id=137 ><a href="-censored-">Node2.4.1.1</a></li>
                        </ul>
                     </li>
                </ul>
            </li>
        </ul>
    </li>
</ul>
</div>

then the js function converting that list into a jstree is:

`

$("#unidadtree").jstree({
    "themes" : {
        "theme" : "custom",
        "dots" : false,
        "icons" : true,
    }
});`

The problem is that, few times (about 1 of each 50 times) the javascript function seems to not load properly. The result that i see is a normal html <ul> & <li> structue. The really strange issue is the low frequency of the error. Could be not my fault? Is someone else having this problem?

thank you very much for your time! :D

Upvotes: 0

Views: 567

Answers (1)

Dave L.
Dave L.

Reputation: 9781

It could be because your ID attributes are invalid. In HTML, you should not have all-numeric values for ID. See this post: What are valid values for the id attribute in HTML?

Also, the ID's should be surrounded by quotes within the source.

I have experienced cases where all-numeric ID's like you have, have led to unexpected results in some browsers.

Upvotes: 2

Related Questions