Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't trigger show #43

Open
paulfalgout opened this issue Dec 26, 2016 · 1 comment
Open

Don't trigger show #43

paulfalgout opened this issue Dec 26, 2016 · 1 comment
Assignees

Comments

@paulfalgout
Copy link
Member

The tutorial currently has:

var App = new Marionette.Application({
  onStart: function(options) {
    var todo = new TodoView({
      collection: new Backbone.Collection(options.initialData.items),
      model: new ToDoModel()
    });
    todo.render();
    todo.triggerMethod('show');
  }
});

App.start({initialData: initialData});

In v3 rendering and "showing" your own view would be greatly discouraged, and I don't think you should really do it in v2 either.. some views will not know they are attached if a region is not involved.

I understand why we got to this place because we were moving away from Application.Regions and because there was no clear place to start a LayoutView, but I would still say that this is a better pattern in v2. Then the change in v3 is to change the regions hash to a simple region: '#app-hook'

I don't know if it is worth the effort of the change, but I've seen this question a bit lately in gitter and SO.

var App = new Marionette.Application({
  regions: {
    'appRegion': '#app-hook'
  },
  onStart: function(options) {
    var todo = new TodoView({
      collection: new Backbone.Collection(options.initialData.items),
      model: new ToDoModel()
    });
    this.getRegion('appRegion').show(todo);
  }
});

App.start({initialData: initialData});
@scott-w
Copy link
Member

scott-w commented Dec 27, 2016

Good shout. I think the issue came from me not having a good plan earlier in Mn 2.x which (I'm pretty sure) I have a working solution using raw RegionManager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants