Coffeescript classes and Backbone.js
You can use Coffeescript classes for Backbone's Models, Views, Collections and Routers:
instead of:
MyView = Backbone.View.extend
events:
'click .test-button': 'someAction'
you can do this:
class MyView extends Backbone.View
events:
'click .test-button': 'someAction'
The cool thing about it is that you can use class methods directly, instead of specifying it as one of the parameters of Backbone's extend method call:
class MyView extends Backbone.View
@imClassMethod: ->
and call it by
MyView.imClassMethod()
Written by Ivan
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Coffeescript
Authors
iam4x
94.17K
ericdfields
63.02K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#