title: Create a JS component from remote call
body: <p>In my Rails5 app I have the JS component below.</p>
  
  <pre><code>class IdentityConfirmation
    constructor: (item) -&gt;
      ...
      @setEvents()
  
    setEvents: -&gt;
      ...
  </code></pre>
  
  <p>I create the components when Turbolinks loads as such </p>
  
  <pre><code>$(document).on 'turbolinks:load', -&gt;
    $.map $("[data-behavior~='identity-confirmation']"), (item, i) -&gt;
      new IdentityConfirmation(item)
  </code></pre>
  
  <p>And everything works just fine.</p>
  
  <p>Now I need to create a component from within a <code>js.erb</code> file.</p>
  
  <p>My js.erb file looks like</p>
  
  <pre><code>$("#mydiv").html("&lt;%= escape_javascript(render partial: 'mypartial' %&gt;"); 
  $.map($("[data-behavior~='identity-confirmation']"), function(item, i) {
    return new IdentityConfirmation(item);
  });
  </code></pre>
  
  <p>And <code>mypartial</code> contains a div with data behavior equal to identity-confirmation.</p>
  
  <p>However, the component is not created.</p>
  
  <p>Am I missing anything here?</p>
  
  <p>Thanks</p>