HomeJavaScript Using Unique and Toggle in a TreeView jQuery Hierarchical Navigation System
Using Unique and Toggle in a TreeView jQuery Hierarchical Navigation System
The TreeView jQuery plug-in is a small yet powerful JavaScript application that allows you to build hierarchical navigation systems whose branches can be collapsed and expanded using different animation effects. So if you’re planning to develop a web site that includes a navigation mechanism like this, start reading this series of articles. In it you’ll find a concise guide that will show you how to master the plug-in’s main features, by means of copious hands-on examples. This article is the fourth of six parts.
Naturally, if you've been a patient reader and already went through the previous chapter of the series, then it's quite possible that you're pretty familiar with the basic capabilities offered by the "TreeView" library. In that particular tutorial I explained how to work with its "animate" option, which can be used for applying a couple of appealing scrolling effects to the branches of a selected tree while they're being closed and extended.
Of course, when it comes to exploring the numerous capacities offered by the "TreeView" plug-in, I must say that there's still a fair bit to learn. It comes packaged with another handy feature that deserve a closer analysis. In this article I'm going to discuss the use of the "unique" and "toggle" arguments, which can be used for customizing the default behavior of a given hierarchical tree even more.
In the first case, the "unique" argument will allow only one branch of the tree to be opened at a time, while the second option will trigger callback functions when the branches are closed and expanded alternately. Of course, this is pure theory that needs to be backed up with some functional code samples, so let's see how to work with these arguments in the context of a few concrete and hopefully educational examples. Let's get going!