Skip to content

Instantly share code, notes, and snippets.

@cmcculloh
Last active June 7, 2018 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cmcculloh/35e6c6c7408cf8d45899 to your computer and use it in GitHub Desktop.
Save cmcculloh/35e6c6c7408cf8d45899 to your computer and use it in GitHub Desktop.
Marionette Cheat Sheet

Base Objects

Basic building blocks (you won't often use these).

Manage the visual regions of your composite application. Composite JS Apps: Regions And Region Managers

Manage one or more related Marionette.Region objects.

The core view class that other Marionette views extend from.

A Behavior is an isolated set of DOM/user interactions that can be mixed into any View. Behaviors allow you to blackbox View specific interactions into portable logical chunks, keeping your views simple and your code DRY.

View Objects

The things you actually use often.

A single item view implementation that contains code for rendering with underscore.js templates, serializing the view’s model or collection, and calling several methods on extended views, such as onRender.

A view that iterates over a Backbone.Collection and renders an individual child view for each model.

Used for rendering a branch-leaf, hierarchical structure. Extends directly from CollectionView and also renders and a child view as modelView, for the top leaf

Used for managing application layoutViews, nested layoutViews and multiple regions within an application or sub-application.

A specialized view class that renders an area of HTML and thenattaches Region instances to the specified regions. Used for composite view management and sub-application areas.

Behaviors is a utility class that takes care of gluing your behavior instances to their given View. The most important part of this class is that you MUST override the class level behaviorsLookup method for things to work properly.

App Objects

These are the shims and glues that bind your app into a cohesive whole

Contain and manage the composite application as a whole. Stores and starts up Region objects, includes an event aggregator as app.vent

A multi-purpose object to use as a controller for modules and routers, and as a mediator for workflow and coordination of other objects, views, and more.

Reduce the boilerplate code of handling route events and then calling a single method on another object. Have your routers configured to call the method on your object, directly. Configure an AppRouter with appRoutes. App routers can only take one controller object. It is recommended that you divide your controller objects in to smaller pieces of related functionality and have multiple routers / controllers, instead of just one giant router and controller. You can also add standard routes to an AppRouter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment