forgot that views need to return self from render

This commit is contained in:
John Bintz 2011-04-15 16:14:18 -04:00
parent 1b91906250
commit 371fa4a05e
3 changed files with 4 additions and 0 deletions

View File

@ -32,6 +32,7 @@ describe 'backbone-generator' do
File.file?(template = 'app/views/section/model.jst').should be_true File.file?(template = 'app/views/section/model.jst').should be_true
File.read(view).should match(/SectionModel/) File.read(view).should match(/SectionModel/)
File.read(view).should match(/return this/)
File.read(view).should match(%r{template: JST\['section/model'\]}) File.read(view).should match(%r{template: JST\['section/model'\]})
File.read(spec).should match(/SectionModel/) File.read(spec).should match(/SectionModel/)
end end
@ -47,6 +48,7 @@ describe 'backbone-generator' do
File.read(view).should match(/SectionModelsView/) File.read(view).should match(/SectionModelsView/)
File.read(view).should match(/SectionModelView/) File.read(view).should match(/SectionModelView/)
File.read(view).should match(/return this/)
File.read(view).should match(%r{template: JST\['section/models'\]}) File.read(view).should match(%r{template: JST\['section/models'\]})
File.read(spec).should match(/SectionModelsView/) File.read(spec).should match(/SectionModelsView/)
end end

View File

@ -11,6 +11,7 @@ var <%= object_name %>sView = Backbone.View.extend({
}, },
render: function() { render: function() {
$(this.el).html(this.template()); $(this.el).html(this.template());
return this;
}, },
addOne: function(model) { addOne: function(model) {
var view = new <%= object_name %>View({model: model}); var view = new <%= object_name %>View({model: model});

View File

@ -5,6 +5,7 @@ var <%= object_name %>View = Backbone.View.extend({
}, },
render: function() { render: function() {
$(this.el).html(this.template()); $(this.el).html(this.template());
return this;
} }
}); });