Skip to main content
June 30, 2008
Question

Collapsible spry - dynamic

  • June 30, 2008
  • 1 reply
  • 320 views
I try to make a "collapsible spry widget" repeating dynamical (by a recordset (I tried also with spry data-xml))
get the same problem, the first collaps work fine but the other are open and do not work,
Does anyone know if it is possible to do so ?
thanks

1- recordset:
<?php do { ?>
<div id="CollapsiblePanel1" class="CollapsiblePanel">
<div class="CollapsiblePanelTab" tabindex="0"><b><?php echo $row_master1artist['prenom_artist']; ?><?php echo $row_master1artist['nom_artist']; ?></b></div>
<div class="CollapsiblePanelContent">
<?php
if ($totalRows_master1artist>0) {
$nested_query_detail2liste = str_replace("123456789", $row_master1artist['id_art'], $query_detail2liste);
mysql_select_db($database_connection);
$detail2liste = mysql_query($nested_query_detail2liste, $connection) or die(mysql_error());
$row_detail2liste = mysql_fetch_assoc($detail2liste);
$totalRows_detail2liste = mysql_num_rows($detail2liste);
$nested_sw = false;
if (isset($row_detail2liste) && is_array($row_detail2liste)) {
do { //Nested repeat
?>
<tr>
<td><span class="style1">Gallerie:</span>  <?php echo $row_detail2liste['name_gall']; ?>-<br />
<span class="style2">Description:</span> <?php echo $row_detail2liste['text_gall']; ?><br />
<span class="style2">example link:</span> <?php echo $row_detail2liste['link_gall']; ?><br /></td>
</tr>
<?php
} while ($row_detail2liste = mysql_fetch_assoc($detail2liste)); //Nested move next
}
}
?>
</div>
</div>
<?php } while ($row_master1artist = mysql_fetch_assoc($master1artist)); ?><p> </p>
<script type="text/javascript">
<!--
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
//-->
</script>


-------------

Spry data:

<div spry:region="ds1">
<div spry:repeat="ds1">

<div id="CollapsiblePanel1" class="CollapsiblePanel">
<div class="CollapsiblePanelTab" tabindex="0">{prenom_artist}</div>
<div class="CollapsiblePanelContent">Content</div>
<script type="text/javascript">
<!--
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1");
//-->
</script>
</div>
</div>
</div>
This topic has been closed for replies.

1 reply

Inspiring
July 1, 2008
Nikko2 wrote:
> I try to make a "collapsible spry widget" repeating dynamical (by a recordset
> (I tried also with spry data-xml))
> get the same problem, the first collaps work fine but the other are open and
> do not work,
> Does anyone know if it is possible to do so ?

What you've done with your code is to give each code block that would ordinarily create a collapsible panel and repeated everything. However that code block depends on the wrapper DIV to have a unique id. So you've got a couple of choices, one: increment the id for the wrapper block so that it changes from CollapsiblePanel1 to CollapsiblePanel2, etc. YOu can do this with code similar to the following:
<?php
$counter = 1;
?>
<?php do { ?>
<div id="CollapsiblePanel<?php echo ($counter); ?>" class="CollapsiblePanel">
.....rest of code here.....

Then you'll need to reset the recordset (see the code added when populating a select list with dynamic data from a recordset), and then do a repeat around the script block at the end and also increment the id that is passed into the Collapsible panel constructor.


*Or* you can use a Collapsible Panel Group and combine that with incremented id for the panel wrapper DIV (code shown above). You can see an example here (check the source code for the page):
http://labs.adobe.com/technologies/spry/samples/collapsiblepanel/CollapsiblePanelGroupSample.html

Note that a set of panels are wrapped with a div similar to this:
<div id="CollapsiblePanelGroup1" class="CollapsiblePanelGroup">
</div>

And then to create the group you use code similar to the following code to replace the current script block:

<script language="JavaScript" type="text/javascript">
var cpg1 = new Spry.Widget.CollapsiblePanelGroup("CollapsiblePanelGroup1");
</script>



--
Danilo Celic
| http://blog.extensioneering.com/
| WebAssist Extensioneer
| Adobe Community Expert