title: Render rails partial on select change
body: <p>I have a nested_form that looks like:</p>
  
  <pre><code>&lt;% form_for @store, do |f| %&gt;
     &lt;%= f.fields_for :products do |builder| %&gt;
        &lt;%= builder.select :typeis, %w[test test1 test2], {}, class: "select_product" %&gt;
        &lt;div class='productHere'&gt;&lt;/div&gt;
     &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Basically, what I want to do is onChange of the select, take the value of the select and render a partial like:</p>
  
  <pre><code>&lt;%= f.hidden_field :name, value: "blah" %&gt;
  </code></pre>
  
  <p>using the value. So if the value of the select is <strong>test1</strong>, I want to render _test1.html.erb.</p>
  
  <p>I've tried doing:</p>
  
  <pre><code>&lt;script type='text/javascript'&gt;
    $(function (){
       $(".select_product").on("change", function (){
          alert(&lt;%= render 'product_form/test', f:builder %&gt;);
       });
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>But this doesn't work. What am I doing wrong?</p>
  
  <p>Thanks for any and all help!</p>