Backbone.Marionette is a composite application library for Backbone.js that aims to simplify the construction of large scale JavaScript applications. Do NOT use this tag for Firefox's Marionette driver. Use the firefox-marionette tag instead.
Backbone.Marionette is a collection of common design and implementation patterns found in the applications that we have been building with Backbone, and includes pieces inspired by composite application architectures, event-driven architectures, messaging architectures, and more.
Important to note that Marionette introduced some breaking changes in their API when moving from 1.X to 2.X below is a quick summary of the main breaking changes that can cause errors in your app, a full report on the changes can be found on google docs.
General
- All instances of the word
type
in the API have been replaced with the wordclass
. For instance:- regionType => regionClass
- ChildViewType => ChildViewClass
Applications and Modules
- Application’s
initialize
triggerMethods have been renamed tostart
, which is more descriptive of what is actually happening. More specifically,initialize:before
andinitialize:after
are nowbefore:start
andstart
, respectively. Note that no functionality has been lost with this change; it is merely a changing of names.
Controllers
close
has been renamed todestroy
to emphasize the fact that an instance should not be reused, or ‘opened,’ after it is destroyed
Regions
Regions now expose
region.el
andregion.$el
, just like View’s. Due to this change if you were depending onregion.el
to be a string selector you must update your code to useregion.$el.selector
.The
open
method has been renamed toattachHtml
Views
Layout
is now calledLayoutView
- Renamed
close
todestroy
for views. Close was a confusing verb for users who thought that they could be reopened. The verb destroy makes it more clear that once a view is destroyed you can not reuse it. - Returning false from
onBeforeClose
no longer prevents the view from closing appendHtml
has been renamed toattachHtml
.appendBuffer
has been renamed toattachBuffer
- Removes duplicate and inconsistent
itemView
events. No functionality was lost with this change; simply use the unprefixed version instead. For instance, usebefore:render
instead ofitem:before:render
- childEvents callbacks no longer receives the event name as the first argument
itemView
within acollectionView
is now known aschildView
. This removes confusion for new users as to the fact that you can show any type of view in yourcollectionView
.- All CollectionView methods that referenced
itemView
now use the samechildView
as well. For instance,getItemView
is nowgetChildView
. Do note that CompositeViews extend from CollectionView, so these API changes affect that Class as well.
References