For example, create a folder called SpryAssets in the root folder of your web site, and move the SpryCollapsiblePanel.js file to it. The SpryCollapsiblePanel.js file contains all of the information necessary for making the Collapsible Panel widget interactive.
<script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
Make sure that the file path to the SpryCollapsiblePanel.js file is correct. This path varies depending on where you’ve placed the file in your web site.
<link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
Make sure that the file path to the SpryCollapsiblePanel.css file is correct. This path varies depending on where you’ve placed the file in your web site.
<div id="CollapsiblePanel1" class="CollapsiblePanel"> </div>
<div id="CollapsiblePanel1" class="CollapsiblePanel"> <div class="CollapsiblePanelTab">Tab</div> </div>
<div class="AccordionPanel"> <div class="CollapsiblePanelTab">Tab</div> <div class="CollapsiblePanelContent">Content</div> </div>
Insert the content between the opening and closing CollapsiblePanelContent tags (For example, Content, as in the preceding example). The content can be any valid HTML code, including HTML form elements.
<div id="CollapsiblePanel1" class="CollapsiblePanel"> . . . </div> <script type="text/javascript"> var cp1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1"); </script>
The new JavaScript operator initializes the Collapsible Panel widget object, and transforms the div content with the ID of CollapsiblePanel1 from static HTML code into an interactive collapsible panel object. The Spry.Widget.CollapsiblePanel method is a constructor in the Spry framework that creates collapsible panel objects. The information necessary to initialize the object is contained in the SpryCollapsiblePanel.js JavaScript library that you linked to at the beginning of this procedure.
Make sure that the ID of the collapsible panel’s div tag matches the ID parameter you specified in the Spry.Widgets.CollapsiblePanel method. Make sure that the JavaScript call comes after the HTML code for the widget.
The complete code looks as follows:
<head> ... <link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" /> <script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script> </head> <body> <div id="CollapsiblePanel1" class="CollapsiblePanel"> <div class="CollapsiblePanelTab">Tab</div> <div class="CollapsiblePanelContent">Content</div> </div> <script type="text/javascript"> var cp1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1"); </script> </body>