title: Static methods & inheritance in Coffeescript
body: <p>I've been reading up a bit about coffeescript's inheritance model and I have the feeling I'm on the fringes of an ideological debate which I really don't understand. So, I would be perfectly happy to find out that I'm just doing things in the wrong way.</p>
  
  <p>Basically what I am doing is writing a set of widgets which, among other things, need to handle events on their DOM elements. I thought a good way to go about this would be to have a class method which would be called once, to delegate all the events which the widget might need. The base widget class might have some simple click handlers, while the subclass might add to that some mouseover handlers or extra click handlers.</p>
  
  <p>However, it appears that I'm not supposed to try and do the equivalent of calling <code>super()</code> inside a static method. There is a workaround which exists, (<code>this.__super__.constructor.METHODNAME()</code> but I've seen a lot of suggestions that this isn't the best way to do what I'm trying to do. Has anyone got any insights on how I should structure this code? Keep using the workaround, or put all the delegation into a totally different place? I can't really just stick it in the prototype, since I won't necessarily have an instance to call the method on (or can I essentially still call a method on the prototype from a static context, like putting <code>SwatchableWidget.prototype.delegateEvents()</code> into an onload function or something?</p>
  
  <p>Here's a bit of code to illustrate what I'm talking about:</p>
  
  <pre><code>class Widget
      @testProp: "ThemeWidget"
      @delegateEvents: -&gt;
          console.log "delegate some generic events"
  
  class SwatchableWidget extends Widget
      @testProp2 = "SwatchWidget"
      @delegateEvents: -&gt;
          console.log "delegate some specific swatchable widget events"
          this.__super__.constructor.delegateEvents()
  
  Widget.delegateEvents()
  SwatchableWidget.delegateEvents()
  </code></pre>
  
  <p>Thanks for any help.</p>