# How to collapse all with a toggle

**URL:** <https://www.ruby-forum.com/t/how-to-collapse-all-with-a-toggle/82642>\
**Category:** Rails\
**Created:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/how-to-collapse-all-with-a-toggle/82642 "2007-01-19T16:31:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![patcito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/50afbb/32.png) [@patcito](https://www.ruby-forum.com/u/patcito)\
**Post date:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/how-to-collapse-all-with-a-toggle/82642/1 "2007-01-19T16:31:57Z")

</div>

Hey all,

I have a loop that kind of looks like this:

\<% for item in @items %\>  
\<% item.id  
%\>  
\<%= link\_to\_remote ‘show other ids’, :url=\>{:action=\>showall} %\>  
  
\<%end%\>

What I want to do is when “show other ids” is clicked, the content of  
each span is showed (eg. with a toggle) except for the span that goes  
with the link that’s been clicked.  
any idea how to do this?

Thanx in advance

Pat

---

<div class="post-metadata">

**Author:** ![patcito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/50afbb/32.png) [@patcito](https://www.ruby-forum.com/u/patcito)\
**Post date:** [September 25, 2007, 10:37pm UTC](https://www.ruby-forum.com/t/how-to-collapse-all-with-a-toggle/82642/2 "2007-09-25T22:37:12Z")

</div>

Patrick A. wrote:

> any idea how to do this?  
> In the end, the answer will be a combination of RJS and CSS. In terms  
> of  
> what exactly that needs to look like, I’m not grokking what you want it  
> to  
> look like initially. Right now what you have above will show a bunch of  
> rows where each row is a link that says ‘show other ids’. And that’s  
> all.  
> More info needed to assist.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![patcito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/50afbb/32.png) [@patcito](https://www.ruby-forum.com/u/patcito)\
**Post date:** [September 25, 2007, 10:39pm UTC](https://www.ruby-forum.com/t/how-to-collapse-all-with-a-toggle/82642/3 "2007-09-25T22:39:48Z")

</div>

what is display is:  
(item.id) ‘show other ids’  
with item.id being hidden.

let’s say I have:  
(1) ‘show other ids’  
(2) ‘show other ids’  
(3) ‘show other ids’

now if I click on the second ‘show other ids’, then it will change the  
rows to:  
1 ‘show other ids’  
(2) ‘show other ids’  
3 ‘show other ids’

with 1 and 3 visible and 2 still hidden. See what I mean?

thanx in advance

Pat
