Rails 3 + Ajax: how to access my local form builder instance

前端 未结 2 1077
南笙
南笙 2021-02-04 10:49

I have a form that displays a set of inputs. I also have a button, and when clicked, I make an ajax request which is supposed to replace the existing inputs with a different set

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-04 11:30

    Can you use fields_for in your partial, and pass the @object to it? That way you don't need to pass a form builder?

    partial:

    <%= fields_for object do |f| %>
      f.text_field :field_name
    <% end %>
    


    $('#info').html("<%= escape_javascript(render 'my_second_fields_partial', object: @object) %>
    

提交回复
热议问题