views:

17

answers:

0

I have followed the instructions in Chapter 13 of Advanced Rails Recipes. However, one of the fields for my nested model uses scriptaculous’ autocompleter.local. The drop down shows up for the first record in the nested model, but doesn’t show up for the others after I click the “Add” button. Any ideas? Here is my code from the partial:

    <div class = "building">
    <% new_or_existing = building.new_record? ? 'new' : 'existing' %>
    <% prefix = "rent_comparable[#{new_or_existing}_building_attributes][]" %>
    <% fields_for prefix, building do |building_form| -%>
    <tr><td>
    <%= building_form.text_field :primary_type_id %>
    <%= building_form.text_field :primary_type_name, 
    :size => "50", 
    :onkeypress => "return event.keyCode == Event.KEY_RETURN ? false : true" %>
    <div class="auto_complete" id='building_primary_type_auto_complete'></div>
    <script type="text/javascript">
    //<![CDATA[
    var building_primary_type_auto_completer = new Autocompleter.Local(
    'rent_comparable_new_building_attributes__primary_type_name', 
    'building_primary_type_auto_complete', 
    primary_type_names_spaces, 
    { minChars:-1, 
    frequency: 0.01, 
    choices: 100, 
    partialSearch: true, 
    partialChars: 1, 
    fullSearch: true } )
    //]]>
    </script>
   </td></tr>
    <% end -%>
    </div>