Rico
Rico Basic Accordion
src="examples/client/images/valid-html401.png"
alt="Valid HTML 4.01 Strict" height="31" width="88">
Overview
This example illustrates how to use the Rico.Accordion behavior to transform a set of
divs into a first class accordion component.
The Rico.Accordion is actually a very simple component built off of Rico behaviors and effects.
It adds the necessary event handlers on the respective divs to handle the visual aspects of expanding, collapsing
and hovering.
HTML Code
The example HTML structure is an outer div that holds all of the panels. Then, each panel is just a
couple of DIVs (one for the header and one for the content) wrapped in an outer DIV. You can actually use
elements other than divs.
<div id="accordionDiv">
<div id="overviewPanel">
<div id="overviewHeader">
Overview
</div>
<div id="panel1Content">
... content text ...
</div>
</div>
</div>
Rico Code
To attach the accordion behavior to the accordion container div, construct a Rico.Accordion
object and pass the panel titles and contents to it. This is a bit different than the previous version,
but allows a lot more flexibilitiy. With the new Prototype Selector class it is still very easy.
new Rico.Accordion( $$('div.panelheader'), $$('div.panelContent') );
-or-
new Rico.Accordion( $$('div.panelheader'), $$('div.panelContent'),
{panelHeight:200,
hoverClass: 'mdHover',
selectedClass: 'mdSelected'}} );
The second example specifies the height of the accordion panels and the css classes that can be associated
with the accordion behaviors.
There are many other configuration parameters that can be specified to modify various visual aspects of the
accordion. The panelHeight is the attribute that is most commonly overridden.
Important Note
The accordion is very flexible now and can handle scrollbars on firefox through the use of some new features in Rico.
However, you do have to make sure the header and content elements passed in to the Accordion constructor have the same
elements and match up in the order they are passed. The new Accordion requires far less html attributes than Rico's
previous versions.