How to update (ajax) partial form after loading for nested fields in rails 3.2? -
on railscasts.com episode #74 presents way dynamically adding partial form nested fields existing form. here helper method playing magic:
def link_to_add_fields(name, f, association) new_object = f.object.class.reflect_on_association(association).klass.new fields = f.fields_for(association, new_object, :child_index => "new_#{association}") |builder| render :partial => association.to_s, :locals => {:f => builder, :i_id => 0} end link_to_function(name, "add_fields(this, \"#{association}\", \"#{j fields}\")") end
here illustration of adding partial form in view:
<p><%= link_to_add_fields t("add product"), f, :order_items %></p>
here illustration of partial form order_items
used in our rails app:
<%= f.input :quote_id, :label => t("quote#"), :collection => @quotes, :include_blank => true %> .......
the order_items
has @quotes
. when user selects supplier, nowadays quotes belong supplier (@quotes = @quotes.where(:supplier_id => the_supplier_id). problem @quotes on partial order_items
can not updated (or don't know how) after beingness loaded first time. possible update @quotes
on partial order_items
ajax phone call after loading?
ruby-on-rails ajax ruby-on-rails-3 forms
No comments:
Post a Comment