HomeJavaScript Adding Elements to a Tree with TreeView jQuery
Adding Elements to a Tree with TreeView jQuery
When it comes to building hierarchical menus that will be used as part of web-based navigational interfaces, one of the best solutions available today is a powerful jQuery plug-in called TreeView. This package comes with a number of handy options that allow you to create collapsible trees very quickly by using only a few simple nested HTML lists. This is the conclusion to a six-part series that uses numerous code samples to show you how to master the main features provided by the TreeView library.
Naturally, if you've read the previous installment of this series, it's quite possible that you already have a clear idea of how to utilize the great variety of options offered by this plug-in to create truly dynamic hierarchical trees. In that specific article, I explained how to use the "persist" parameter to easily save the state of a given tree across several HTTP requests.
In reality, the "persist" option takes two possible values. The first one, called "location," allows you to maintain the settings of the tree via the "href" attributes of the hyperlinks that comprise it, while the second one, identified as "cookie," obviously saves the tree's state by using some cookies.
However, it's worth mentioning that the "TreeView" plug-in offers an additional feature, named "add," that deserves a close analysis. It can be employed to dynamically add elements to a selected tree. Therefore, in this last chapter of the series I'm going to discuss how to work with it, thus finishing this introductory overview to this powerful jQuery plug-in.
Ready to tackle the final episode of this educational journey? Then let's get going!