Like a Boss!

Manage your Marionette.js sub-views...

BossView, an extension of Marionette.js, is an abstraction that manages events and rendering of sub-views. Using sub-views is such a common pattern, you will never stop using BossView.

Dependencies: jQuery, underscore.js, backbone.js and marionette.js.

Examples

Marionette.js Standalone
Marionette.js w/ BossView
Render a Sub-view
Render a Sub-view and listen for events
Render a Sub-view in a Containing Element
CodePen Example

See the Pen yleij by Justin (@justspamjustin) on CodePen

Docs

BossView Basics
BossView is an extension of the Marionette.ItemView. You have access to all of the same methods that Marionette.ItemView has.
subViews
Specify your views in the 'subViews' object. BossView will automatically render these sub-views for you when the BossView is rendered. The key becomes the instance of the subView on the parent view. On the right, you can either specify a function and initialize your view manually, returning the instance, or just specify the view class and BossView will initialize it for you.
subViewEvents
For the sake of decoupling views, subViews should only communicate to its parent view through events. The 'subViewEvents' object allows you to treat your subView events in the same way you would handle dom events with the 'events' object. If you want to listen to all subviews for an event, just use the '*' character for the subViewName. Also, BossView will bubble each of the events of the sub-views by prepending the name of the subview (ie. 'someSubView:render').
subViewContainers
Sometimes you will want to render your subViews inside of a containing element of your BossView. Do this by implementing the 'subViewContainers' object. The key should correspond the name of the subView that you specified in the 'subViews' object. The property should be the jQuery selector of the containing element.
mainSubViewContainer
Sometimes you may want to have all of the subViews render inside one parent div without having to specify the same subView container for each subView. To do this, just specify a jQuery selector for the 'mainSubViewContainer' property. All subViews will be rendered in the container except any subViews that have been specified in 'subViewContainers'.
subViewRenderConditions
Sometimes you may want to only render your subViews under some condition. In this case, provide a 'subViewRenderConditions' object. Define a function that returns truthy or falsey.