eatorres
eatorres

Reputation: 179

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.

Upvotes: 0

Views: 99

Answers (2)

eatorres
eatorres

Reputation: 179

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();

Upvotes: 1

T J
T J

Reputation: 43156

From the 3.0 release blog:

RegionManager

Marionette.RegionManager was removed. This publicly exposed class was mostly used as a common class used between LayoutView and Application.

The upgrade guide doesn't seem to mention RegionManager at all.

If you are looking for a codemod or something I'm not aware of any. But there is this marionette-3-patch for backwards compatibility with marionette 2, which you can use for upgrade and gradually re-write the 2.x syntax manually or create tooling.

Upvotes: 0

Related Questions