fields_for is not defined when partial is calling from js.erb in rails 3.1.4
===

Partial customer_quote_record is called from js.erb like this:

    $("<%= escape_javascript(render 'invoices/customer_quote_record', :f=> @f ) %>");

@f is a form builder defined in invoice controller like this:

    @f = ActionView::Helpers::FormBuilder.new(:invoice, @invoice, self, {}, proc {} ) 

The partial form looks like this:

    <%= f.simple_fields_for :invoice_items do |ff| %>
       <%= ff.input :quote_id, :label => 'Quote#：', :collection => quotes_for_invoice(@invoice.customer_id), :label_method => :quote_date, :value_method => :id,  :include_blank => true %>
       <%= ff.hidden_field :_destroy %>  
     <% end %>

The error is that when `$("<%= escape_javascript(render 'invoices/customer_quote_record', :f=> @f ) %>")` is executed, There is a error:

    ActionView::Template::Error (undefined method `fields_for'

The error disappears if replace f.simple_fields_for with simple_fields_for. However the association between invoice and invoice_items can not maintained which causes error when saving the invoice. Any idea about the problems? Thanks so much.




