title: rails - Retrieving parent form after ajax call
body: <p>I'm not sure if what i'm trying to do is possible but i'd appreciate your ideas.</p>
  
  <p>I have a nested form accepts a parent form and renders a partial. I want to dynamically add nested object. I've tried the implementation described in the <a href="http://railscasts.com/episodes/196-nested-model-form-revised" rel="nofollow">Nested Model Form</a> railscast
  but since the nested model is in itself complex and requires fields to be divided to two forms, this implementation turns out very clumsy..</p>
  
  <p>What i'm trying to do is call an action remotly, add a nested object to the original model, and have that action render a js that appends the partial to be rendered. like this:</p>
  
  <p><strong>custom_action.js.erb</strong></p>
  
  <pre><code>$('#room_info')
      .html("&lt;%= j render(:partial =&gt; 'room_info', :locals =&gt; {:f =&gt; f }) %&gt;");
  </code></pre>
  
  <p>Where room_info is a div nested under the parent form and "f" is the parent object's form. Is there any way to retrieve this form variable, "f"? Maybe with jQuery? </p>
  
  <p>Any help will be appreciated. Thanks!</p>