more fixes
This commit is contained in:
parent
6b31491da7
commit
b0a8425617
|
@ -7,12 +7,13 @@ class window.<%= plural_object_name %>View extends Backbone.View
|
|||
@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())
|
||||
@collection.each(this.addOne)
|
||||
addNew: =>
|
||||
facility = new <%= object_name %>()
|
||||
@collection.add(facility)
|
||||
|
|
|
@ -16,3 +16,11 @@ describe '<%= plural_object_name %>View', ->
|
|||
expect(view.$('.list')).toContain('.<%= css_class_name %>')
|
||||
expect(collection.length).toEqual(1)
|
||||
|
||||
it 'should render the models when re-rendered', ->
|
||||
expect(view.$('.list')).not.toContain('.<%= css_class_name %>')
|
||||
|
||||
model = new <%= object_name %>({id: 1})
|
||||
collection.add(model)
|
||||
view.render()
|
||||
|
||||
expect(view.$('.list')).toContain('.<%= css_class_name %>')
|
||||
|
|
Loading…
Reference in New Issue