I have a view, seen below, that shows a list of churches if the zip code isn't 01540 or 01537. This part works perfectly. The problem is that this is the page is to edit an existing record also, so observe_field needs to see that the zip code currently doesn't match, so the church list needs to be shown. Currently, even if the zip doesn't match, the list will only be shown after the field is changed, even is the field is changed to the same value.. Here is the view, controller code and church_select view in that order.. Please give me a direction to look..
Thanks
Bob <bsm2th@gmail.com>
View <STYLE TYPE="text/css"> <!-- big{font-family: Arial; font-size: 16pt;} ---> </STYLE> <% fields_for @household, :builder => TaggedBuilder do | household_form| %> <pre> <div id="household"> <%= household_form.text_field :first_name, :maxlength => 50, :size => 15, :autocomplete => "off", :class => 'household ' %> <%= household_form.text_field :middle, :size => 1, :maxlength =>1, :autocomplete => "off", :class => 'household ' %> <%= household_form.text_field :last_name, :maxlength => 50, :size => 20, :autocomplete => "off", :class => 'household ' %> <%= household_form.text_field :address, :autocomplete => "off", :class => 'household ' %> <%= household_form.text_field :zip, :size=> 5, :autocomplete => "off", :class => 'household ' %> <%= household_form.text_field number_to_phone(:phone, :area_code => true), :autocomplete => "off", :size => 14, :class => 'household ' %> </div> <%= observe_field :household_zip, :url => {:controller => 'households', :action => 'watch_church'}, :update => :church, :with => ':zip', :frequency=> 0.5 %> <div id="church"> </div> <u><b>Federal Programs</b></u> <b>Primary Income </b><%= household_form.select(:primary, [['1. Employment', 1],['2. Unemployment', 2],['3. SSI', 4],['4. TANF/EADC', 8],['5. Other', 16], ['6. None', 32]], :class => "household ") %> <table> <tr><td><%= household_form.check_box :food_stamps %></
</tr>
<tr><td><%= household_form.check_box :wic %></td></tr> <tr><td><%= household_form.check_box :school_breakfast %></
</tr>
<tr><td><%= household_form.check_box :school_lunch %></td></
<tr><td><%= household_form.check_box :SFSD %></td></tr></
</b></pre> <% end %>
controller def watch_church # debugger if (params[':zip'] != "01540") && (params[':zip'] != "01537") then render :partial => "church_select" else render(:nothing=>true) end end
church_select view <b>Member of Local Church: </b> <%= collection_select('household', 'church_id', Church.find(:all), 'id', 'name') %>