title: d3.js CoffeeScript class execution context
body: <p>I am creating a d3.js chart using a CoffeeScript class.  I would like to attach a method to a click event, and then run another method depending on what was clicked: </p>
  
  <pre><code>class @Chart
  
    drawChart: -&gt;
       ...
  
      dataArea
        .enter()
          .append("path")
            .on("click", @onClick);
       ...
  
    onClick: -&gt;
      if d3.select(this).attr("type") == 'video'
        @runVideo(d3.select(this).attr("title"))
  
    runVideo: -&gt;
  </code></pre>
  
  <p>The problem is that in the onClick method the execution context ("this") is the selection and not the Chart class, so "runVideo is not a function."  How can I access selection attributes from within the onClick method and also run the runVideo method?  </p>