title: Dynamic Javascript in my .html.erb
body: <p>I'm struggling with some Javascript in my first rails application.</p>
  
  <p>Partial: _care_point.html.erb</p>
  
  <pre><code>&lt;script&gt;
    $(function() {
      $( ".draggable" ).draggable({grid: [50, 20]});
      $( ".node_input").each (function() {
        $(this).hide();
      });
      $("#&lt;%="node.#{care_point.id}" %&gt;").live('dblclick', function(){
        console.log('moo');
        jQuery(this).hide();
        jQuery('.node_input', jQuery(this).parent()).show();
      });
    });
  &lt;/script&gt;
  &lt;div id=&lt;%="care_point.#{care_point.id}" %&gt; class='draggable node_chin'&gt;
    &lt;div id=&lt;%="node.#{care_point.id}" %&gt; class='node'&gt;&lt;%= care_point.body %&gt;
    &lt;/div&gt;
    &lt;textarea class='node_input'&gt;&lt;%= care_point.body %&gt;&lt;/textarea&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is the output:</p>
  
  <pre><code>    &lt;script&gt; 
    $(function() {
      $( ".draggable" ).draggable({grid: [50, 20]});
      $( ".node_input").each (function() {
        $(this).hide();
      });
      $("#node.1").live('dblclick', function(){
        console.log('moo');
        jQuery(this).hide();
        jQuery('.node_input', jQuery(this).parent()).show();
      });
    });
  &lt;/script&gt; 
  &lt;div id=care_point.1 class='draggable node_chin'&gt; 
    &lt;div id=node.1 class='node'&gt;Moo foo
    &lt;/div&gt; 
    &lt;textarea class='node_input'&gt;Moo foo&lt;/textarea&gt; 
  &lt;/div&gt;
  </code></pre>
  
  <p>I first added the dblclick event listener classbased, but that caused it to be added multiple times. This made me change it to a id based approach, but now it does not work. Is it because I try to dynamically build up the id?</p>
  
  <p>Is this even the righ place to do this kind of thing?</p>