22 lines
584 B
Plaintext
22 lines
584 B
Plaintext
class window.<%= plural_object_name %>View extends Backbone.View
|
|
events: {
|
|
'click button.new': 'addNew'
|
|
}
|
|
template: JST['<%= plural_underscore_name %>/list']
|
|
initialize: ->
|
|
@collection.bind('refresh', this.addAll)
|
|
render: =>
|
|
$(this.el).html(this.template())
|
|
this.addAll()
|
|
this
|
|
addOne: (model) =>
|
|
view = new <%= object_name %>View({model: model})
|
|
this.$('.list').append(view.render().el)
|
|
addAll: =>
|
|
@collection.each(this.addOne)
|
|
addNew: =>
|
|
facility = new <%= object_name %>()
|
|
@collection.add(facility)
|
|
this.addOne(facility)
|
|
|