justspamjustin / BossView

Manage your Marionette.js views like a boss! Manages events and rendering of sub-views.
http://justspamjustin.github.io/BossView/
MIT License
48 stars 6 forks source link

A better comparison for the child view in a container #1

Closed mxriverlynn closed 10 years ago

mxriverlynn commented 10 years ago

Hi there! I saw your project via a tweet and had to check it out. It looks pretty sweet! I like the direction you're heading. The declarative child view events are especially awesome. Nicely done on that. :)

I did want to suggest a better version of sub view in a containing element sample, though. Marionette's Layout provides exactly this, though it may have a slightly different focus than what you're showing.

But to keep the code comparison a little more clean, I'd recommend updating that sample to look like this:

var SubView = Marionette.ItemView.extend({
  template: function() {
    return 'something';
  },
});

var TopView = Marionette.ItemView.extend({
  template: function() {
    return '<div class="some-container"></div>';
  },

  regions: {
    someContainer: '.some-container'
  },

  onRender: function() {
    this.someContainer.show(new SubView());
  }
});

It's not quite as condensed as your configuration, still, but it gives a more accurate depiction of what Marionette can do.

justspamjustin commented 10 years ago

@derickbailey I'm glad you found BossView! I updated the container example with your code.

mxriverlynn commented 10 years ago

oops! I forgot to change the view type:

var TopView = Marionette.Layout.extend({

not ItemView, but Layout ... sorry about that.

justspamjustin commented 10 years ago

No problem. Just updated it. Thanks.