Search code examples
backbone.jsmarionette

How can I replace RegionManager instances on Marionette 3


I am currently upgrading a project from Marionette v2 to v3 but it seems all of the functionality of the region manager was added into the View class.

My project has several instances of

Marionette.RegionManager.extend({
  regions: {
    ...
  }
})

I was wondering if there is a way of directly converting v2 code like this into v3 code.


Solution

  • I found that the region manager can be replaced by a view, acting as the root for all other views. It is sufficient to add it to the application as stated in the Application documentation

    var Mn = require('backbone.marionette');
    var RootView = require('./views/root');
    
    
    var App = Mn.Application.extend({
      region: '#root-element',
    
      onStart: function() {
        this.showView(new RootView()); // Which is your old region manager
      }
    });
    
    var myApp = new App();
    myApp.start();