Post Archive

› March 18, 2005

DOM-Scripted Lists, Revisited

  • Reported by Dave

Speaking of speaking of javascript that enhances websites without complicating markup, harming accessibility, or even posing degradation problems, here is my own contribution. Following up on a brief article I wrote a few years ago, this expandable list implementation shores up a lot of the shortcomings of its predecessor. I tried to distill the concept of an expandable unordered list down to its simplest form, while still maintaining flexibility. I discuss some of the design decisions I made in the accompanying article, DOM-Scripted Lists, Revisited.

Comments

1. April 3, 2005 06:49 AM

Quote this comment

Egor Kloos Posted…

Looking at the script I'm saddened to see the use of 'style.display=none'. HTML for content structure, CSS for style and layout and javascript for behaviour. So why not alter the 'className' insted of using styles in javascript?

2. April 3, 2005 11:53 AM

Quote this comment

David Lindquist Posted…

Hello Egor. Thanks for the response.

I don't really see the advantage of altering the class name instead of the style property directly in this case. I consider the expanding and collapsing to be integral to the behavior of the script, and thus independent of any style sheet. If the onus was on the style sheet author to provide the classes necessary to enable the script, then that would seem to me to violate the "separation of powers" you mention above.

3. April 3, 2005 11:54 AM

Quote this comment

Nate Posted…

I don't know Egor, that seems like you're splitting hairs.

4. April 3, 2005 12:45 PM

Quote this comment

David Lindquist Posted…

Also, for those interested, I made a few changes to the script. It now supports ordered as well as unordered lists, and adds two new configurable options to make the switch's title text a little more descriptive.

5. April 3, 2005 08:25 PM

Quote this comment

Egor Kloos Posted…

Yes, I'm splitting hairs. And the opening and closing of an element can be seen as behaviour. But it's being done via the use of style rules anyway. So why not use classnames with a more discriptive and semantic nature? Like 'on' or 'off', 'open' or 'closed'. The visual rendering of that or other underlying elements can be controlled by the CSS. Also the script itself becomes more generic.

6. April 3, 2005 10:25 PM

Quote this comment

Posted…

Egor, I respect your opinion. You certainly have a point from a purist's perspective. However, I stand by my previous comment. You are certainly welcome to change the script in any way you see fit.

Also, I think I have reached a milestone in my short and ignoble scripting career. This marks the first time I have ever saddened anyone with a script. Usually the only person I make sad with my programming skills is me. :)

7. April 4, 2005 05:57 AM

Quote this comment

Egor Kloos Posted…

Don't mind me, I'm very easily saddened. And thus have a tendency to be slightly melodramatic.

I'll have a look if can adapt the script to show you what I mean. The script itself is actually fine. It's just that I love nitpicking and finding ways to make my work easier to maintain.

8. April 20, 2005 01:28 AM

Quote this comment

Alex Posted…

I’d like to put a question. Why you avoid setAttribute() function usage? Thank you.

9. May 12, 2006 06:08 AM

Quote this comment

Ady G Posted…

it seems "gazingus" has faded into the ether, even google's cache has lost it :( would love to read the article sometime