Skip to content

Instantly share code, notes, and snippets.

@pnegri
Created October 19, 2012 13:15
Show Gist options
  • Save pnegri/3918172 to your computer and use it in GitHub Desktop.
Save pnegri/3918172 to your computer and use it in GitHub Desktop.
class IuguDatasetComponent extends IuguBaseComponent
defaults:
presenterName: "iugu-dataset-component"
itemPresenterName: "iugu-dataset-record-component"
baseURL: ""
fields: ""
initialize: ->
super
_.bindAll @, 'render', 'addRecord'
@collection.on('all', @render)
@
addRecord: (item) ->
@els.push (
new IuguDatasetRecordComponent
model: item
baseURL: @options.baseURL
presenterName: @options.itemPresenterName
fields: @options.fields
).render().el
render: ->
$(@el).html JST[@presenterFile()] dataset: @collection, options: @options
@els = []
@collection.each @addRecord
@$('.records').append(@els)
@
@IuguDatasetComponent = IuguDatasetComponent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment