Hello all,
I am trying to incorporate 4 single-panel accordion elements in a Hub site that I'm currently developing. I've got it working based on this thread noted in the source comment below. I'm not a Javascript person, so I need some help.
I've repeated this code for all 4 panels, changing the panel element names, but right now, only the top panel is collapsed when the page loads. What do I need to change in order for all 4 individual panels to be collapsed on page-load?
Thanks in advance for any help or suggestions!
Catherine
<!-- Safety Panel -->
<!-- Source: https://community.esri.com/thread/191483-calcite-map-opening-one-panel-from-another#comment-671513 -->
<div id="panelSafety" class="panel collapse in">
<div id="headingSafety" class="panel-heading" role="tab">
<div class="panel-title">
<a class="panel-toggle collapsed" role="button" data-toggle="collapse" href="#collapseSafety" aria-expanded="false" aria-controls="collapseSafety"></a><div style="background: rgba(41,43,71,1.0); color: #fff; padding: 5px; height: 65px;"><a class="panel-toggle collapsed" role="button" data-toggle="collapse" href="#collapseSafety" aria-expanded="false" aria-controls="collapseSafety">
<h5>Safety Measures<br></h5><span class="glyphicon glyphicon-info-search" aria-hidden="true"></span></a>
<a class="panel-close" role="button" data-toggle="collapse" data-target="#panelSafety"><span class="esri-icon esri-icon-close" aria-hidden="true"></span></a>
</div>
</div>
<div id="collapseSafety" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingSafety" aria-expanded="false" style="height: 0px;">
<div class="panel-body calcite-body-expander">
<div class="panel-body">
<p>
<img src="/sandbox/images/safety_sm.png">
</p>
<p></p><p><strong>text here</h6>
<a href="https://community.esri.com/pages/safety" class="btn btn-primary">Click to learn more</a><p></p>
<a href="#BackToTop">Back to Top</a><p></p>
</div>
</div>
</div>
</div></div>
Graham Hudgins Is there anyone at ESRI who can help us get this working?
These panels work by targeting the class names. So if you use `panelSafety` in all 4 then you'll run into issues. You need to give each panel its own name and wire up the close actions too. You can also wire up a "parent" so that the other close when you open a new one. I recommend googling "bootstrap accordion" or "bootstrap collapse" as there is a wealth of examples
i've improved your example a small amount but didn't put the parent on so they both stay open
```
<!-- Safety Panel -->
<!-- Source: https://community.esri.com/thread/191483-calcite-map-opening-one-panel-from-another#comment-671513 -->
<div id="panelSafety" class="panel collapse in">
<div id="headingSafety" class="panel-heading" role="tab">
<div class="panel-title">
<a class="panel-toggle collapsed" role="button" data-toggle="collapse" href="#collapseSafety" aria-expanded="false" aria-controls="collapseSafety"></a><div style="background: rgba(41,43,71,1.0); color: #fff; padding: 5px; height: 65px;"><a class="panel-toggle collapsed" role="button" data-toggle="collapse" href="#collapseSafety" aria-expanded="false" aria-controls="collapseSafety">
<h5>Safety Measures<br></h5><span class="glyphicon glyphicon-info-search" aria-hidden="true"></span></a>
<a class="panel-close" role="button" data-toggle="collapse" data-target="#panelSafety"><span class="esri-icon esri-icon-close" aria-hidden="true"></span></a>
</div>
</div>
<div id="collapseSafety" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingSafety" aria-expanded="false" style="height: 0px;">
<div class="panel-body calcite-body-expander">
<div class="panel-body">
<p>
<img src="/sandbox/images/safety_sm.png">
</p>
<p></p><p><strong>text here
<a href="https://community.esri.com/pages/safety" class="btn btn-primary">Click to learn more</a></strong></p><p></p><strong>
<a href="#BackToTop">Back to Top</a><p></p>
</strong></div><strong>
</strong></div><strong>
</strong></div><strong>
</strong>
</div>
</div>
<div id="panelOther" class="panel collapse in">
<div id="headingOther" class="panel-heading" role="tab">
<div class="panel-title">
<a class="panel-toggle collapsed" role="button" data-toggle="collapse" href="#collapseOther" aria-expanded="false" aria-controls="collapseOther"></a><div style="background: rgba(41,43,71,1.0); color: #fff; padding: 5px; height: 65px;"><a class="panel-toggle collapsed" role="button" data-toggle="collapse" href="#collapseOther" aria-expanded="false" aria-controls="collapseOther">
<h5>Safety Measures<br></h5><span class="glyphicon glyphicon-info-search" aria-hidden="true"></span></a>
<a class="panel-close" role="button" data-toggle="collapse" data-target="#panelOther"><span class="esri-icon esri-icon-close" aria-hidden="true"></span></a>
</div>
</div>
<div id="collapseOther" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOther" aria-expanded="false" style="height: 0px;">
<div class="panel-body calcite-body-expander">
<div class="panel-body">
<p>
<img src="/sandbox/images/safety_sm.png">
</p>
<p></p><p><strong>text here
<a href="https://community.esri.com/pages/safety" class="btn btn-primary">Click to learn more</a></strong></p><p></p><strong>
<a href="#BackToTop">Back to Top</a><p></p>
</strong></div><strong>
</strong></div><strong>
</strong></div><strong>
</strong>
</div>
</div>
```
Hi Graham, thanks for your reply, but as I mentioned, I had already changed the panel element names for all 4....that wasn't the problem. I was eventually able to get this working with the help of our web admin. We'd spent a good bit of time on googling code samples from multiple sites, including ESRI code samples. Samples from calcite-web and calcite-maps didn't always work together. Samples from a straight Bootstrap 4 example would not work in the Hub text box object. Either the panels would only render as plain text, or or the panels would render but without the accordion function.
We did eventually get this to work. Part of my issue was that I had assumed each panel had to be in its own individual text box object. I switched it so that all 4 accordion panels were in a single text box object. I had to close each working panel in its individual text box, then copy the closed panel & paste it into the "shared" text box object. It finally worked. Once all 4 panels were working correctly as a single unit, I tried copying the identical code in into a different Hub site that we're building, but now the panels do NOT work. It's just been frustrating trying to get some of these elements to behave correctly.
It would be really helpful if we could get access to the parent CSS file behind the Hub sites...I think that would resolve some of these issues we've experienced. Hope this helps someone else trying to get this to work.
Sorry I misunderstood! I didn't realize you had already tried that or that you were trying to use custom HTML across text cards. I can see why that would be frustrating. A few clarifying points that may help you (or others) in the future:
This is all good info! Esp. re: Bootstrap 3 vs. 4...I think the samples that I was trying to use were for version 4. I will also try out the iframe card and see if that makes any difference on the other site. Thanks for the reply.
Catherine- I am trying to do the same thing and I am NOT a coder. I ran into the same problems you did. Is there any way you could share the final code that worked so I can see what I am doing wrong? '
Thank you!
Gabrielle