Joined April 2014
·

Erik Nomitch

Prelang
·
Chicago, IL
·
·

Posted to CoffeeScript mixins in Backbone over 1 year ago

Thanks for this. The only issue I ran into was trying to use super in the instance methods since Coffeescript will error due to detecting super being called outside of an instance method when it parses the mixin code.

I got around this by manually finding/calling the super method:

@Foo =
  bar: () ->
    # Do something...
    # Falling back to super if found
    if superMethod = @constructor.__super__[arguments.callee.name]
      superMethod.apply @, arguments

If you know of a better way, please let me know!

Erik

Achievements
89 Karma
0 Total ProTip Views