title: How to call my jquery function in an html.erb file from a js.erb file in the same view folder
body: <p>I've got a draw function that runs on page load, here is the <code>html.erb file</code> excerpt:</p>
  
  <pre><code>&lt;div class="canvasarea"&gt;
  &lt;canvas id="myCanvas" width="360" height="840"&gt;&lt;/canvas&gt;
  &lt;/div&gt;
  
  &lt;script&gt; 
  //definition of vars used in draw function...
  
   window.onload = function() {
      window.setTimeout(drawSomething,500)
    };
  
    function drawSomething() {
      context.drawImage(imageObj, xOffset, yOffset);
    }  
   &lt;/script&gt;
  </code></pre>
  
  <p>I want to redraw this image when a button is pushed on the page.  That button lives in an html.erb file.  It currently replaces some <code>tr</code>s.  I want to call the <code>drawSomething()</code> function when the button is pressed.  The <code>.js.erb file</code>:</p>
  
  <pre><code>&lt;% @pos_range.each do |p|%&gt;
      $("td#add_foo_&lt;%= p %&gt;").replaceWith("&lt;%= escape_javascript(render(:partial =&gt; 'bars/update_foo_position', :locals =&gt; { :id =&gt; @foo.id, :position_str =&gt; @position_str, :position =&gt; p} ))%&gt;");
      &lt;% if (@foo and p == @foo.position) or @pos_range.length == 1 %&gt;
          $("td#add_foo_button_&lt;%= p %&gt;").replaceWith("&lt;%= escape_javascript(render(:partial =&gt; 'bars/update_foo_position_button', :locals =&gt; { :id =&gt; @bar.id, :position_str =&gt; @position_str, :position =&gt; p} ))%&gt;");
      &lt;% else %&gt;
          $("td#add_foo_button_&lt;%= p %&gt;").replaceWith("&lt;%= escape_javascript(render(:partial =&gt; 'bars/update_foo_position_empty', :locals =&gt; { :id =&gt; @bar.id, :position_str =&gt; @position_str, :position =&gt; p} ))%&gt;");
      &lt;% end %&gt;
  &lt;% end %&gt;
  
  &lt;% if @foo%&gt;
      $("#tr_&lt;%=@foo.name %&gt;").hide()
  &lt;% end %&gt;
  $("#dialog").dialog("close").remove();
  </code></pre>