[jQuery] [treeview] - How to manually set a persistent location
I'm using the treeview plugin for navigation on our website. It works
great but I wanted to be able to override the persist:location when
needed. For example, on an e commerce site where items are part of a
category, I need to have that tree open to that category.
To achieve this, I hacked (and I mean hacked, I'm no jQuery guru, but
it works) the jquery.treeview.js file to add another check for a
location. Here is what I did.
Around line 207 I added this....
if(typeof myLocation != "undefined") {
var current1 = this.find("a").filter(function() { return
this.href.toLowerCase() == myLocation.toLowerCase(); });
if ( current1.length ) {
current1.addClass("selected").parents("ul, li").add
( current1.next() ).show();
}
}
Then, in my pages I manually set the myLocation variable like this....
<script language="JavaScript">
myLocation = "http://your/server/name/and/url/path";
</script>
Then, VIOLA!
I hope that helps anyone else who is trying to achieve this.