# How do I make toggle appear not disapear

**URL:** <https://www.ruby-forum.com/t/how-do-i-make-toggle-appear-not-disapear/116078>\
**Category:** Rails\
**Created:** [October 2, 2007, 4:55am UTC](https://www.ruby-forum.com/t/how-do-i-make-toggle-appear-not-disapear/116078 "2007-10-02T04:55:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbowerma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/73ab20/32.png) [@kbowerma](https://www.ruby-forum.com/u/kbowerma)\
**Post date:** [October 2, 2007, 4:55am UTC](https://www.ruby-forum.com/t/how-do-i-make-toggle-appear-not-disapear/116078/1 "2007-10-02T04:55:31Z")

</div>

In my partial I iterate displaying many ‘roles’ in a side bar.  
each role has 0 or more services. I then iterated over the services  
and set their div id to that of the parent service ( you will notice  
in the code that I had to take the white space out with the delete  
tag.

I made a link\_to\_function that will toggle on the service div id.  
This works well but when the page is rendered I see the services but i  
want them hidden by default. How do I set the toggle to default hide  
the div id?

Thanks in advance Kyle.

\<% divid = role.name.delete " " %\>

```
  <%= link_to_function role.name do |page|
    page.toggle divid
    end
  %>

  <% @role = role%> </li>
  <div id=<%= divid %> >
     <% for service in @role.services -%>
        <ul style ="font-size: 80%; color: #99cc99; text-indent: 

```

1em"\>  
\<%= service.name %\>   
\<% end -%\>

---

<div class="post-metadata">

**Author:** ![kbowerma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/73ab20/32.png) [@kbowerma](https://www.ruby-forum.com/u/kbowerma)\
**Post date:** [October 2, 2007, 11:22am UTC](https://www.ruby-forum.com/t/how-do-i-make-toggle-appear-not-disapear/116078/2 "2007-10-02T11:22:44Z")

</div>

> ```
> <% @role = role%> </li>
> <div id=<%= divid %> >
> <% for service in @role.services -%>
> <ul style ="font-size: 80%; color: #99cc99; text-indent: 
> 
> ```
> 
> 1em"\>  
> \<%= service.name %\>   
> \<% end -%\>

how bout setting

> ```
> <div id=<%= divid %> >
> 
> ```

to \<div id=\<%= divid %\> style=“display:none;”\>

---

<div class="post-metadata">

**Author:** ![kbowerma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/73ab20/32.png) [@kbowerma](https://www.ruby-forum.com/u/kbowerma)\
**Post date:** [October 2, 2007, 4:02pm UTC](https://www.ruby-forum.com/t/how-do-i-make-toggle-appear-not-disapear/116078/3 "2007-10-02T16:02:14Z")

</div>

Perfect! I have been trying to figure that out for three days.  
Thank you so much Shai

On Oct 2, 4:22 am, Shai R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
