Skip to content

Commit 050bc1d

Browse files
author
Derick Bailey
committed
fixed the broken 'first render' logic. fixes marionettejs#295
1 parent dfde7d6 commit 050bc1d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/marionette.layout.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Marionette.Layout = Marionette.ItemView.extend({
1313
// Ensure the regions are avialable when the `initialize` method
1414
// is called.
1515
constructor: function () {
16+
this._firstRender = true;
1617
this.initializeRegions();
1718
Backbone.Marionette.ItemView.apply(this, arguments);
1819
},
@@ -22,13 +23,16 @@ Marionette.Layout = Marionette.ItemView.extend({
2223
// views that the regions are showing and then reset the `el`
2324
// for the regions to the newly rendered DOM elements.
2425
render: function(){
25-
// If this is not the first render call, then we need to
26-
// re-initializing the `el` for each region
27-
if (!this._firstRender){
26+
27+
if (this._firstRender){
28+
// if this is the first render, don't do anything to
29+
// reset the regions
30+
this._firstRender = false;
31+
} else {
32+
// If this is not the first render call, then we need to
33+
// re-initializing the `el` for each region
2834
this.closeRegions();
2935
this.reInitializeRegions();
30-
} else {
31-
this._firstRender = false;
3236
}
3337

3438
var result = Marionette.ItemView.prototype.render.apply(this, arguments);

0 commit comments

Comments
 (0)