Re rendering into a form/table

I have this inside of a template where I have a remote form with the
form fields inside of a table:

<%= render :partial => 'ingredients', :locals => {:attr => attr} %>

my “_ingredients.html.erb” template is like so:


<%= link_to 'Add Ingredient', {:action => 'add_ingredient', :id =>attr}, :remote => true %>

<% attr.my_ingredients.each do |ingred| %>
<%= fields_for ‘ingredient[]’,ingred do |fm| %>

<% fld = 'del-' + ingred.id.to_s %> <%= check_box_tag fld %> <%= observe_field fld, :frequency => 0.5, :url => {:action => 'delete_ingredient', :id => ingred} %> Name <%= fm.text_field 'ingred_name', :value => ingred.name %> Cas <%= fm.text_field 'cas', :value => ingred.cas %> &nbsp <% end %> <% end %>

my rjs actions try to delete/add an ingredient record or add one and
then re render
the partial like this:

page.replace_html ‘ingredients_div’, :partial =>
‘ingredients’, :locals => {:attr => attr}

I can’t remember if there is some html rule with form fields or table
rules, but the html seems to get modified as the page kind of
twitches, but the fields don’t redisplay as they should. The view
source confuses me as it appears the div moved someplace else and left
the old fields intact where they where.

On 11 October 2011 20:38, Jedrin [email protected] wrote:

<% attr.my_ingredients.each do |ingred| %>
ingred.name %>

twitches, but the fields don’t redisplay as they should. The view
source confuses me as it appears the div moved someplace else and left
the old fields intact where they where.

You have not shown us how the form itself is fitted into or around the
table. A form cannot lie inside a table unless it is entirely within
one cell. A table can lie entirely within a form.

If you are not sure whether you have valid html copy the entire page
source (View > Page Source or similar in your browser) and paste it
into the w3c html validator. Once you have valid html then try the
remote stuff again.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs