Skip to content

Instantly share code, notes, and snippets.

@esmevane
Created June 14, 2012 16:49
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save esmevane/2931439 to your computer and use it in GitHub Desktop.
Save esmevane/2931439 to your computer and use it in GitHub Desktop.
class Example.Views.Table extends Backbone.View
template: JST['example/table']
initialize: ->
_.bindAll @, 'addOne', 'addAll'
@collection.on 'add', @addOne
render: ->
@$el.html @template()
@addAll()
@
addOne: (person) ->
view = new Example.Views.Row model: person
@$el.append view.render().el
addAll: -> @collection.each (person) => @addOne person
class Example.Views.Row extends Backbone.View
template: JST['example/row']
render: ->
@$el.html @template @model
@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment