0

I have a root layout with two regions. One of them is simple ItemView, but another is LayoutView. When the second region try to show a LayoutView i receive an error

application.rootView.getRegion(...).show is not a function

in console. Can anyone help me to understand why this happening?

Views:

_RootView = Marionette.LayoutView.extend({
    el: 'body',
    regions: {
        navigationRegion: {
            selector: '.section-navigation',
            regionClass: _NavigationRegion
        },
        contentLayout: {
            selector: '.section-content',
            regionClass: _ContentLayout
        }
    }
});

_ContentLayout = Marionette.LayoutView.extend({
    template: '#content-template',
    regions: {
        contentRegion: {
            selector: '.content',
            regionClass: _ContentRegion
        },
        pagemasterRegion: {
            selector: '.pagemaster',
            regionClass: _PagemasterRegion
        }
    }
});

Application:

application = new _Application({
    initialize: function (options) {
        this.rootView = new _RootView();
    }
});

application.on('start', function () {
    var
    contentLayout = new _ContentLayout();

    var
    navigation = new _Navigation();

    navigation.fetch({
        success: function (collection, response, options) {
            var
            navigationView = new _NavigationView({
                collection: collection
            });
            //======Line without error=======
            application.rootView
                .getRegion('navigationRegion')
                .show(navigationView);
        }
    });

    //======Line with error=======
    application.rootView
        .getRegion('contentLayout')
        .show(contentLayout);
});

application.start();
Evgeniy
  • 3,219
  • 5
  • 25
  • 40
  • Problem solved. In my _RootView i specify regionClass: _ContentLayout, but _ContentLayout is not a Region. – Evgeniy Dec 16 '15 at 19:58

1 Answers1

0

You should render layout before showing it:

application.rootView.render();
application.rootView
        .getRegion('contentLayout')
        .show(contentLayout);
Alexander Shlenchack
  • 3,779
  • 6
  • 32
  • 46
  • The same error. As I know .show() render template without calling .render(). – Evgeniy Dec 16 '15 at 13:41
  • When I use your advice console take an error about "Template is undefined". Ok, it's right because i don't use a template in _RootView. For example, my navigation view render application.rootView .getRegion('navigationRegion') .show(navigationView); without problems. – Evgeniy Dec 16 '15 at 14:11