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
typein the API have been replaced with the wordclass. For instance:- regionType => regionClass
- ChildViewType => ChildViewClass
Applications and Modules
- Application’s
initializetriggerMethods have been renamed tostart, which is more descriptive of what is actually happening. More specifically,initialize:beforeandinitialize:afterare nowbefore:startandstart, respectively. Note that no functionality has been lost with this change; it is merely a changing of names.
Controllers
closehas been renamed todestroyto emphasize the fact that an instance should not be reused, or ‘opened,’ after it is destroyed
Regions
Regions now expose
region.elandregion.$el, just like View’s. Due to this change if you were depending onregion.elto be a string selector you must update your code to useregion.$el.selector.The
openmethod has been renamed toattachHtml
Views
Layoutis now calledLayoutView- Renamed
closetodestroyfor 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
onBeforeCloseno longer prevents the view from closing appendHtmlhas been renamed toattachHtml.appendBufferhas been renamed toattachBuffer- Removes duplicate and inconsistent
itemViewevents. No functionality was lost with this change; simply use the unprefixed version instead. For instance, usebefore:renderinstead ofitem:before:render - childEvents callbacks no longer receives the event name as the first argument
itemViewwithin acollectionViewis 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
itemViewnow use the samechildViewas well. For instance,getItemViewis nowgetChildView. Do note that CompositeViews extend from CollectionView, so these API changes affect that Class as well.
References