Welcome!

AJAX & REA Authors: John Funnell, Bob Little, Kevin Hoffman, Maureen O'Gara, Onkar Singh

Related Topics: AJAX & REA, ColdFusion, Adobe Flex

AJAX & REA: Article

Simplifying AJAX with the Spry Framework

Delivering great experiences while fitting the workflows and skill sets of both designers & developers

Widget Structure
In our example we use an Accordion widget to display additional information about the selected product in the Products table. The structure of the widget is defined by the HTML code.

As you can see, the composition of the widget is quite easy to understand for anybody familiar with HTML. If you want to add or delete a panel, you can simply add or delete the appropriate HTML container in your code.

Widget Behavior
The functionality for the Accordion widget is built into a JavaScript file that understands the HTML structure for the widget. This approach makes it easy for users to modify the look-and-feel of the widget without having to worry about its functionality. As long as the HTML structure is correct, the widget will function as expected. The JavaScript is included using two lines of code.

The first line simply links in the JavaScript file that contains the Accordion functionality.

The second line creates an instance of the Accordion JavaScript object and links it to the HTML by passing in the user-defined ID (Acc1).

Note that the JavaScript to create an instance of a Spry widget must be included under your markup at the bottom of the Web page.

Widget Styling
The Accordion widget is styled just as you would any other HTML element on your page using CSS. The CSS file (SpryAccordion.css) is included using the following line of code:

In the HTML example in Figure 8 you will notice that there are CSS classes applied to each of the relevant block-level elements (Accordion, AccordionPanel, AccordionPanelTab, and AccordionPanelContent). The CSS rules for these classes are defined in the SpryAccordion.css file. They can be changed at will by the Web developer or designer.

Spry Effects
Spry effects are visual enhancements that you can apply to almost any element on an HTML page. For example, an effect might highlight information, create animated transitions, or visually alter a page element for a certain period of time. Effects are a simple but elegant way of enhancing the look-and-feel of your Web site.

The current set of effects (so far) includes:

  • Appear/Fade
  • Highlight
  • Blind Up/Blind Down
  • Slide Up/Slide Down
  • Grow/Shrink
  • Shake
  • Squish
The Effect philosophy follows the Spry guiding principles:
  • Simple JS Syntax.
  • Single JS include.
  • Compatible with other effect libs/frameworks.
  • Focus on key interaction/UE behaviors.

More Stories By Paul Gubbay

Paul Gubbay is a director of engineering at Macromedia. Previously, Paul held the role of CEO at CyberSage Software, where he spent several years building the vision and infrastructure of the company. Under Paul's guidance, CyberSage focused on emerging technologies such as XML, Java, and Macromedia Flash to deliver leading edge product offerings.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.