[jQuery] Re: Treeview plugin for navigation - solution

2009-07-16 Thread Matt B.

Sorry for the repeat posts, but the link above was incorrect (I'm at a
different computer right now). This is the revision I used:

http://dev.jquery.com/browser/trunk/plugins/treeview/jquery.treeview.js?rev=4685

...although there appear to be more recent revisions...I'm not sure
which is best.


On Jul 16, 12:06 pm, "Matt B."  wrote:
> Edit: I realized that "cookieOptions" is actually a version 1.4.1
> feature, only available from the SVN. The feature has not yet been
> added to the minified version, so you need to grab the uncompressed
> version here:
>
> http://dev.jquery.com/browser/trunk/plugins/treeview/jquery.treeview.js
>
> So it's not undocumented, it's just that 1.4.1 hasn't officially been
> released yet.
>
> On Jul 16, 8:45 am, "Matt B."  wrote:
>
> > I just thought I'd post a solution I came up with that may be helpful
> > to anyone using thetreeviewplugin fornavigation.
>
> > The problem I ran into was that the cookie persistence was working,
> > but since I was using the tree fornavigationto different directories
> > of my site, sometimes the cookie wouldn't get set correctly and the
> > state of the tree would end up being one step behind what the user had
> > just clicked -- so the previously clicked node would be expanded
> > rather than the current one.
>
> > Thanks to some helpful posts I found on here, I discovered that the
> > problem was the cookie path.
>
> > The solution is to use an (undocumented) option that was added to the
> > plugin as of version 1.4: 'cookieOptions', which lets you set the
> > cookie path.
>
> > If yournavigationtree could potentially be used for any page in your
> > domain, then you would set the cookie path to the root, like this:
>
> > cookieOptions: {path: '/'}
>
> > ..or if your site is in a subdirectory you should use this:
> > cookieOptions: {path: '/my_subdirectory/'}
>
> > In my case I'm using PHP and I have my site root stored in a constant
> > called WEB_ROOT, so my full code was:
>
> >         $(document).ready(function() {
> >                 $("#sideNav ul").treeview({
> >                         collapsed: true,
> >                         unique: true,
> >                         persist: "cookie",
> >                         cookieOptions: {path: ''}
> >                 });
> >         });
>
> > Hope this is helpful to somebody.


[jQuery] Re: Treeview plugin for navigation - solution

2009-07-16 Thread Matt B.

Edit: I realized that "cookieOptions" is actually a version 1.4.1
feature, only available from the SVN. The feature has not yet been
added to the minified version, so you need to grab the uncompressed
version here:

http://dev.jquery.com/browser/trunk/plugins/treeview/jquery.treeview.js

So it's not undocumented, it's just that 1.4.1 hasn't officially been
released yet.


On Jul 16, 8:45 am, "Matt B."  wrote:
> I just thought I'd post a solution I came up with that may be helpful
> to anyone using thetreeviewplugin fornavigation.
>
> The problem I ran into was that the cookie persistence was working,
> but since I was using the tree fornavigationto different directories
> of my site, sometimes the cookie wouldn't get set correctly and the
> state of the tree would end up being one step behind what the user had
> just clicked -- so the previously clicked node would be expanded
> rather than the current one.
>
> Thanks to some helpful posts I found on here, I discovered that the
> problem was the cookie path.
>
> The solution is to use an (undocumented) option that was added to the
> plugin as of version 1.4: 'cookieOptions', which lets you set the
> cookie path.
>
> If yournavigationtree could potentially be used for any page in your
> domain, then you would set the cookie path to the root, like this:
>
> cookieOptions: {path: '/'}
>
> ..or if your site is in a subdirectory you should use this:
> cookieOptions: {path: '/my_subdirectory/'}
>
> In my case I'm using PHP and I have my site root stored in a constant
> called WEB_ROOT, so my full code was:
>
>         $(document).ready(function() {
>                 $("#sideNav ul").treeview({
>                         collapsed: true,
>                         unique: true,
>                         persist: "cookie",
>                         cookieOptions: {path: ''}
>                 });
>         });
>
> Hope this is helpful to somebody.


[jQuery] Treeview plugin for navigation - solution

2009-07-16 Thread Matt B.

I just thought I'd post a solution I came up with that may be helpful
to anyone using the treeview plugin for navigation.

The problem I ran into was that the cookie persistence was working,
but since I was using the tree for navigation to different directories
of my site, sometimes the cookie wouldn't get set correctly and the
state of the tree would end up being one step behind what the user had
just clicked -- so the previously clicked node would be expanded
rather than the current one.

Thanks to some helpful posts I found on here, I discovered that the
problem was the cookie path.

The solution is to use an (undocumented) option that was added to the
plugin as of version 1.4: 'cookieOptions', which lets you set the
cookie path.

If your navigation tree could potentially be used for any page in your
domain, then you would set the cookie path to the root, like this:

cookieOptions: {path: '/'}

..or if your site is in a subdirectory you should use this:
cookieOptions: {path: '/my_subdirectory/'}

In my case I'm using PHP and I have my site root stored in a constant
called WEB_ROOT, so my full code was:

$(document).ready(function() {
$("#sideNav ul").treeview({
collapsed: true,
unique: true,
persist: "cookie",
cookieOptions: {path: ''}
});
});

Hope this is helpful to somebody.