View comments | RSS feed

Spry

Open panels programmatically

You can programmatically open different panels by using JavaScript functions. For example, you might have a button on your page that opens a particular accordion panel when the user clicks the button.

 Use the following JavaScript functions to open accordion panels:
<input type="button" onclick="acc10.openFirstPanel()" >open first panel</input>
<input type="button" onclick="acc10.openNextPanel()" >open next panel</input>
<input type="button" onclick="acc10.openPreviousPanel()" >open previous panel</input>
<input type="button" onclick="acc10.openLastPanel()" >open last panel</input>
<script type="text/javascript">
	var acc1 = new Spry.Widget.Accordion("Accordion1");
</script>
You can also use acc10.openPanel(panelNumber) to open any panel. The accordian panels use a zero-based counting system, so setting the value to 2 opens the third panel.

Comments


No screen name said on Apr 23, 2008 at 6:55 PM :
It shouold be acc1 or acc10 ???
jonmichael said on Apr 27, 2008 at 11:15 AM :
Yes, you're right. Good catch.

You can use either acc1 or acc10, just as long as the widget name is consistent throughout the code.
sinagod said on Aug 14, 2009 at 6:40 PM :
This is not an error. Assigning acc10 to an onClick event is proper syntax.
However, there must be an accordion widget with an ID of acc10. If however they really had an accordion widget with an ID of acc1 and assigned acc10 to an event, then there would be an assignment error.
ThomTerrific said on Aug 30, 2009 at 11:38 AM :
This does not work:
<input type="button" onclick="acc10.openPanel(2)" class="detailText">Open Panel 3 </input>

However all of these do:
<input type="button" onclick="acc10.openFirstPanel()" >open first panel</input>
<input type="button" onclick="acc10.openNextPanel()" >open next panel</input>
<input type="button" onclick="acc10.openPreviousPanel()" >open previous panel</input>
<input type="button" onclick="acc10.openLastPanel()" >open last panel</input>

Why?

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/en_US/Spry/SDG/WSE03B96F0-A409-4dc0-830E-EA05F91492D7.html