smithvoice.com
 Y'herd thisun? 

“Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems”
-Jamie Zawinski


from comp.lang.emacs

Sessvars is a great tool

TaggedCoding, ASP.Net

It actually happened, a guy used the contact page to send a note asking where our "cool treeview" went.  Quick answer: I made this left-heavy site style while playing around and I liked it enough to give it a go for a while even though it doesn't have the room for a good tree... I'm toying with ticklers for a while to see how they do for random clicks.

Trees are my fave but now and then you have to dump what you've been doing forever to force yourself to see useful options.

That said...

I love a good treeview on a site, they help casual surfers bounce around easily seeing stuff in all areas.  I'd had one on this sitelett since the beginning, using full java applets, a flash app, a few rather lousy 3rd party ajaxers, even a couple tries at widgets when I was testing out DNN for a client (I can't speak for nuke5 but for anyone going beyond the top level 4x was, for us, a convoluted distaster pretty much all around).

The thing about all of them except the oldest java applet that was in a frame - remember frames? - was that they didn't retain state.  Meaning that the user would click around opening and closing the tree nodes then when they hit a nodelink to a page they'd redirect BUT on the new page load all of the previously opened nodes would be collapsed again.  IMHO that is not walking like a duck for a real treeview.

I recall two of the ajaxers could retain but in their cases they loaded up their own serverside session vars and I never got a good feel for their SEO usefulness because of the javascript functions for subnode loads rather than actual links.  (Yes, I understand that huge trees fill up every page but good planning of the navigation subsections can help there IF the developer has some control over the logic guts)

Anyway, during a redesign a couple of years back I went alookin' again for anyone else who felt that a tree should fully act like a tree across page changes and didn't find anything obvious BUT I did find a javascript library that did a very neat thing:  it held relatively large vars between page hits in a very interesting place.  The author apparently designed it for reducing or avoiding the traditional use of cookes for one-off data but I wondered.

Since I was a bit better at js than I was years before (when I actually got paid to write it - doh!), I figured with some simple div hiding I could maybe just roll my own to get what I really wanted and offload the state persistance to this library.

And I found that this guy's library was perfect even at the medium bulks that I needed, I just had to hold the user's active/open tree node keys in arrays.  This thing holds a nice amount of data and it is fast.  Of course because I'm using asp.net my code had to hit a serverside cached dataset/lean-xml during init or page load and send the whole hierarchical tree structure to the browser then I needed a js or jquery function to reset the states of all parent nodes of previously opened children (and highlight the current page node) but that was just busywork put in a user control ... and while the full data could get fat on the wire and the client, in my real world use and thinning over iterations it wan't ever a killer and spiders could get to every page href, even the hidden ones.

Bottom line:  Even if you don't care about a good logical treeview, if you need a simple reduction of throw away session data that you're now using cookies or session variables or user-modifiable querystrings (yuk) you should really check this library out.

I'm not a big fan of OP code libraries... it takes real usefulness for me to commit, but I commited to this and was very happy.  It worked flawlessly and quickly on every slow-connection mobile and full major browser that we ever saw used (even Playstation3!).  So concerns over that have been put to rest.

Go get yourself Sessvars.js... and leave the creator Thomas Frank a note after you really use it (I just did, and regret that my cudos were long overdue).

You'll like it.



home     who is smith    contact smith     rss feed π
Since 1997 a place for my stuff, and it if helps you too then all the better smithvoice.com