Ruby on Rails Sunday, May 2, 2010

>>>>_household.html.erb
<%= observe_field :household_zip,
:url => {:controller => 'households', :action => 'watch_church'},
:update => :church,
:with => '@churches',
:frequency=> 0.5 %>

<div id="church">
</div>

>>>>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
<b>Member of Local Church: </b> <% select("church", "church_id",
Church.all.collect{|p| [p.name, p.id]}) %> </div>


On Apr 21, 3:30 am, Colin Law <clan...@googlemail.com> wrote:
> On 21 April 2010 05:38, Bob Smith <bsm...@gmail.com> 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
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment