I have been working with the Fancytree jQuery plug-in written by Martin Wendt and it is fantastic. However, I've been struggling with one particular aspect. I'm using HTML rather than JSON for the data structure of the tree and discovered that it renders with missing nodes.
I spent a fair bit of time narrowing this down to the fact that the Fancytree control must be expecting a single <UL>
structure. Anything else in the structure must be nested under <LI>
. However I do not understand why. Let me explain.
Here is some sample HTML:
<div id="tree">
<UL id="browser" class="filetree">
<LI class="folder">
Folder 1
<UL>
<LI>Nested Folder 1
<UL>
<LI>Subitem1</LI>
<LI>Subitem2</LI>
</UL>
</LI>
</UL>
<UL>
<LI>Nested Folder 2
<UL>
<LI>Subitem1</LI>
<LI>Subitem2</LI>
</UL>
</LI>
</UL>
</LI>
</UL>
</div>
When this HTML is rendered in IE, Chrome or pretty much any browser it correctly appears as two sequential unordered lists with nested items. However, when I apply Fancytree the node "Nested Folder 2" completely vanishes. In fact, there are no JavaScript errors or warnings from the plug-in framework.
Therefore, my question is somewhat two fold:
Based upon W3C standards is the above properly formatted HTML syntax? I think yes.
Why does the Fancytree not render the second folder? Is it a bug with Fancytree? Is there a customization I can easily do to get this to render?
My source for this HTML is dynamic and involves a rather complex XSLT so I'm hoping the answer is not to have to refactor the HTML structure.
I would greatly appreciate any insight that could be offered.