Skip to content

Commit

Permalink
Added a failing spec to demonstrate the Layout.render issue with ev…
Browse files Browse the repository at this point in the history
…ents bound before the first render call (e.x. in the `initialize` function).
  • Loading branch information
osama-lionheart committed Sep 22, 2012
1 parent c51e4e9 commit fb6400d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion spec/javascripts/layout.spec.js
Expand Up @@ -4,6 +4,11 @@ describe("layout", function(){
regions: {
regionOne: "#regionOne",
regionTwo: "#regionTwo"
},
initialize: function() {
if (this.model) {
this.bindTo(this.model, 'change', this.render);
}
}
});

Expand Down Expand Up @@ -167,7 +172,9 @@ describe("layout", function(){
beforeEach(function(){
loadFixtures("layoutManagerTemplate.html");

layout = new LayoutManager();
layout = new LayoutManager({
model: new Backbone.Model()
});
layout.render();
region = layout.regionOne;

Expand All @@ -194,6 +201,15 @@ describe("layout", function(){
var regionEl = layout.$("#regionOne");
expect(region.$el[0]).toBe(regionEl[0]);
});

it("should re-bind the regions correctly when the view's `render` function is bound to an event in the `initialize` function", function(){
layout.onRender = function() {
this.regionOne.show(view);
};

layout.model.trigger('change');
expect(layout.$("#regionOne")).not.toBeEmpty();
});
});

describe("when re-rendering a closed layout", function(){
Expand Down

0 comments on commit fb6400d

Please sign in to comment.