View Full Version : Simple Tree Menu - Closed submenus visible on (re)load

01-27-2007, 09:50 AM
Thread posted here because although I have already fixed this problem, it's something that people may need help with in future. It didn't seem to fit anywhere else, but I apologise in advance if anywhere else is where it belongs.

1) Script Title: Simple Tree Menu

2) Script URL (on DD):

3) Describe problem:

Script behaves unexpectedly when used without included stylesheet.

Whenever a page is (re)loaded, all items in the menu are visible
Attempting to close submenus that were previously set to closed gives no result until the second click.

The second indicates that the submenus previously set to closed are still considered "closed", despite being visible. The script works fine, a quick look through it reveals that the reason for this is there is nothing in the script to set closed menus to display:none; when the page is (re)loaded.

See the example page (http://kiirani.com/~kiirani/test/treemenu/index.html) I've put up for an example of the problem, a more verbose commentary and a solution.

I would love to know why this script is set up this way, if anyone knows.

01-27-2007, 12:24 PM
Thanks for taking the time to detail your issue. You're right, the script does rely on CSS to initially hide the desired folders instead of via scripting, which in hindsight isn't the best approach (ie: user turns of JavaScript). Just so you know, most scripts on DD are updated every few months to include feedback from users as far as bugs or requested features are concerned. So the next time this script is updated, I'll definitely be addressing the aforementioned issue. The more recent scripts dealing with hidden content on DD all take the approach of downgrade compatibility with browsers that may have JavaScript turned off, for example, the updated Switch Content script. (http://dynamicdrive.com/dynamicindex17/switchcontent.htm) It's an ever evolving process for scripts here on DD. :)

01-28-2007, 12:36 AM
Ah, well thank you :) It's good to know that any problems won't be left to rot in your scripts.