If you thought the Tab navigation was good, check out the Sort-able grid script. By
simply setting a class on any table you can make the headers sortable. The script
takes care of numbers, dates and text automatically.
experiments. sorttable makes
any data table on a page “sortable” by clicking the table headers. I’ve seen this
effect used to
demonstrate Microsoft’s proprietary “behaviors” technology but Stuart’s solution has
the advantage of being standards compliant and working across different browsers.
Best of all, it follows the principles of inobtrusive DHTML and
hooks in to the markup using only a class attribute.
Event Sheets, is even more interesting. It tackles the problem of attaching events
to page elements. The most common way of doing this is with inline attributes, but
these require adding behavioural (rather than structural) code to your markup and
can lead to additional maintenance costs further down the road. A better alternative
is to use the DOM to dynamically add events, which works fine but
the events. Stuart’s solution is to abstract the logic that attaches events to elements
syntax (partially handled by my getElementsBySelector
function) to specify how events attached to different elements should be handled.
Stuart demonstrates the idea with a common image rollover: