Skip to content

Commit

Permalink
Merge remote-tracking branch 'recurse/patch-2' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Derick Bailey committed Aug 12, 2013
2 parents 64bae87 + 8400e02 commit 977595e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
17 changes: 17 additions & 0 deletions spec/javascripts/layout.spec.js
Expand Up @@ -293,4 +293,21 @@ describe("layout", function(){
});
});

describe("when rendering a prematurely closed layout", function(){
var region, layout;

beforeEach(function(){
loadFixtures("layoutManagerTemplate.html");

layout = new Layout();
layout.close();
layout.render();
});

it("should re-initialize the regions to the newly rendered elements", function(){
expect(layout).toHaveOwnProperty("regionOne");
expect(layout).toHaveOwnProperty("regionTwo");
});
});

});
13 changes: 7 additions & 6 deletions src/marionette.layout.js
Expand Up @@ -27,15 +27,16 @@ Marionette.Layout = Marionette.ItemView.extend({
// for the regions to the newly rendered DOM elements.
render: function(){

if (this._firstRender){
// if this is the first render, don't do anything to
// reset the regions
this._firstRender = false;
} else if (this.isClosed){
if (this.isClosed){
// a previously closed layout means we need to
// completely re-initialize the regions
this._initializeRegions();
} else {
}
if (this._firstRender) {
// if this is the first render, don't do anything to
// reset the regions
this._firstRender = false;
} else if (!this.isClosed){
// If this is not the first render call, then we need to
// re-initializing the `el` for each region
this._reInitializeRegions();
Expand Down

0 comments on commit 977595e

Please sign in to comment.