# Select inside a hidden div

**URL:** <https://www.ruby-forum.com/t/select-inside-a-hidden-div/187285>\
**Category:** Rails\
**Created:** [April 21, 2010, 6:39am UTC](https://www.ruby-forum.com/t/select-inside-a-hidden-div/187285 "2010-04-21T06:39:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [April 21, 2010, 6:39am UTC](https://www.ruby-forum.com/t/select-inside-a-hidden-div/187285/1 "2010-04-21T06:39:46Z")

</div>

Is there any way to use select inside a hidden div block with a model  
object for the select items ? I have the block showing and hiding OK  
with observe\_field, but the variable I’m using to see whether to show/  
hide seems to be the only one allowed by the :with option to  
observe\_field, so I can’t see a way to get the model variable to the  
select box. I tried leaving it as it was before the observe\_field and  
partial, but it doesn’t see the variable anymore to populate the  
choices…

Please help.

Bob [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [April 21, 2010, 9:40am UTC](https://www.ruby-forum.com/t/select-inside-a-hidden-div/187285/2 "2010-04-21T09:40:40Z")

</div>

On 21 April 2010 05:38, Bob S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there any way to use select inside a hidden div block with a model  
> object for the select items ? I have the block showing and hiding OK  
> with observe\_field, but the variable I’m using to see whether to show/  
> hide seems to be the only one allowed by the :with option to  
> observe\_field, so I can’t see a way to get the model variable to the  
> select box. I tried leaving it as it was before the observe\_field and  
> partial, but it doesn’t see the variable anymore to populate the  
> choices…

I think you will need to show us some view code. The minimum that  
shows the problem please.

Colin

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [May 3, 2010, 7:58am UTC](https://www.ruby-forum.com/t/select-inside-a-hidden-div/187285/3 "2010-05-03T07:58:44Z")

</div>

> > > > \_household.html.erb  
> > > > \<%= observe\_field :household\_zip,  
> > > > :url =\> {:controller =\> ‘households’, :action =\> ‘watch\_church’},  
> > > > :update =\> :church,  
> > > > :with =\> ‘@churches’,  
> > > > :frequency=\> 0.5 %\>

> > > > household\_controller.html.erb  
> > > > def watch\_church  
> > > > if (params[‘zip’] != “01540”) && (params[‘zip’] != “01537”) then  
> > > > render :partial =\> “church\_select”  
> > > > else  
> > > > render(:nothing=\>true)  
> > > > end  
> > > > end

> > > > \_church\_select.hmtl.erb  
> > > > **Member of Local Church:** \<% select(“church”, “church\_id”,  
> > > > Church.all.collect{|p| [p.name, p.id]}) %\>
