Email conversation
From | Matthew Da Silva |
To | Me |
Subject | collapsible tree remains open on returning to page |
Date | 10 May 2004 07:26 |
Hi,
I'm using your collapsibleList.js and it's very nice. I like the way you
can put links into the leaves. There's one issue related to links however.
When you click a leaf's link and then return to the page, the tree is
collapsed again. You'll note that I'd already removed the 'true' arguments
from those leaves in your sample code that had it because I wanted the tree
to be initially quite collapsed.
Anyway, this automatic collapsing can give users navigating the site a
headache when they want info quickly, since they're forced to click the
relevant leaf open again each time they return to the page.
Is it possible to alter the script so that it remembers which leaf was open
when the page was quitted?
Best regards,
Matthew da Silva
From | Me |
To | Matthew Da Silva |
Subject | Re: collapsible tree remains open on returning to page |
Date | 11 May 2004 08:44 |
Matthew,
I have not written any functionality to do this, and it is in fact quite a
big change for it to do so. I'm afraid that I did not consider that when I
originally wrote it (in Opera, it works as you want, because Opera always
remembers the running state of scripts)
I intend to implement this, hopefully in the next few days, and preferably
less than a week.
The following would need to be done:
each expand/contract link would need an id
if a link is expanded, its id should be stored in an array (including
initial state)
when the page detects the unload event, the contents of the array should be
stored in a cookie
after loading, the page should wait (minimum 150 ms), then check that
cookie. if it finds one, it should check every link on the page, and if its
name matches one of the names in the cookie, then it should run the links
onclick event handler
please accept the script as it is right now, and when I update it, I will
let you know, and you can download a new copy. watch this space.
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
From | Matthew Da Silva |
To | Me |
Subject | Re: collapsible tree remains open on returning to page |
Date | 11 May 2004 23:12 |
Mark,
On reflection it makes sense that it should be a large programming
change. Often in website design small changes in the user experience
require large amounts of work to be carried our by the programmer. My
apologies for the inconvenience.
I eagerly look forward to seeing the new script. Please accept my
sincere thanks for your work and consideration.
Regards,
Matthew
From | Matthew Da Silva |
To | Me |
Subject | Re: collapsible tree remains open on returning to page |
Date | 12 May 2004 00:16 |
Mark,
Will your planned changes be made only to the server-side javascript
file or will changes also be made to the code I put into the HTML? Just
had a thought -- so that I don't repeat effort...
Cheers,
Matthew da Silva
From | Me |
To | Matthew Da Silva |
Subject | Re: collapsible tree remains open on returning to page |
Date | 12 May 2004 08:18 |
I suspect that the changes will require you to put an extra <script> tag in
the head of the pages to load my cookie script, and then add two event
handlers in the body tag to detect the onunload and onload events to store
and re-use the setup.
If absolutely necessary, you could edit the script file to make it do these
for you, removing the need for any changes to your HTML (assuming you are
not already using the onload and onunload events for any other scripts).
We will have to wait and see how it looks and works when I am finished.
From | Me |
To | Matthew Da Silva |
Subject | Re: collapsible tree remains open on returning to page |
Date | 16 May 2004 23:10 |
Matthew,
I have made the changes now. the state of the lists can be remembered using
cookies. The only (unfortunate) restriction is that if the list is set to
auto-collapse sibling branches, the status cannot be saved. this is due to
the way that the information would need to be saved, where it would easily
push the size of the cookie beyond the 4 KB cookie limitation. So I am
afraid that it works as well as it is going to.
You can download the latest version from:
http://www.howtocreate.co.uk/jslibs/
From | Matthew Da Silva |
To | Me |
Subject | Re: collapsible tree remains open on returning to page |
Date | 17 May 2004 00:48 |
Hi Mark,
I'm glad you could work out all the problems. It's really terrific that
you could find time to do this. I'm very grateful to you.
There's one thing I can't find however: your cookie script. Searched
high and low and couldn't recognise it among the documentation. Sorry to
bring this up after all your effort.
Regards,
Matt
From | Matthew Da Silva |
To | Me |
Subject | Re: collapsible tree remains open on returning to page |
Date | 17 May 2004 23:53 |
Hi Mark,
I've installed the cookie js in the server, but the system won't
function yet. Possibly I need more details about how to use this (from
the cookie instructions page):
[the cookie script instructions]
I'm wondering where these variables and elements need to be placed
inside the HTML. Sorry for these additional requests, I'm on a steep
learning curve. Currently, I'm getting an error (either on refresh or
when going to another page from a link in this page -- see attached gif)
at line 31, which happens to be the location of
onunload="saveCollapseState(lifeTime);. Also, the tree which had been
expanded is collapsed on returning to this page.
Regards,
Matt
From | Me |
To | Matthew Da Silva |
Subject | Re: collapsible tree remains open on returning to page |
Date | 18 May 2004 09:08 |
Matt,
Sorry for the confusuion.
The changes you need to make are quite minor, and the instructions are
written in the collapsibleList.js file. To summarise:
you need to use this if you want to save/recover a list setup:
createList(myList,'cookieNameToSave');
If you use more than one list and you want to save both, they must have
different cookie names
and you also need to use something like:
<body onunload="saveCollapseState();">
If you put a number between the brackets, it will save for that many
seconds instead of the browser session.
and that should be all.
[ED. ps, you also need to put the extra script tag in the document head to
import the cookie script]
From | Matthew Da Silva |
To | Me |
Subject | Re: collapsible tree remains open on returning to page |
Date | 19 May 2004 00:25 |
Hi Mark,
It works!!!!
The error was being generated because of the value 'lifeTime' in the
body onunload argument (if that's what it's called; the technical
language is still beyond me!).
Thank you for your great service. I'll certainly recommend your website
to anyone wanting useful javascript tools.
Thanks again.
Cheers,
Matthew da Silva