Backbone.Marionette, currently at stable version 4.1.3, is a composite application library designed to bring architectural patterns, view management, and memory management to applications built with Backbone.js. It provides a structured approach to developing large-scale single-page applications by offering components like `Application`, `Region`, `View`, and `CollectionView`. While Backbone offers core building blocks, Marionette extends these with sensible defaults, an event-driven architecture via Backbone.Radio, and built-in lifecycle management, including "zombie-killing" for views. This specific package (`backbone.marionette`) is currently in maintenance mode, with its development limited to bug fixes. All new feature work for the framework has transitioned to a new, dependency-agnostic `marionette` package (v5+), which no longer relies on Backbone. This `backbone.marionette` package requires Backbone v1.3.3+ and Underscore v1.8.3+ as peer dependencies, ensuring its compatibility within the Backbone ecosystem.
npm install backbone.marionetteVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic Marionette Application, define a Region, instantiate an ItemView with a simple template, and display it within the application's region. It also shows how to update the view dynamically.
Consult the official upgrade guide from v3 to v4: `https://marionettejs.com/docs/v4.0.0/upgrade-v3-v4.html` to understand necessary code adaptations.
For new projects or significant feature development, consider migrating to the standalone `marionette` package (v5+) to leverage active development and a future-proof architecture. Existing `backbone.marionette` projects should be aware of the limited future development.
Ensure `backbone` (`^1.3.3`) and `underscore` (`^1.8.3`) are correctly installed and available in your project's `node_modules` and runtime environment.
Always utilize Marionette's `this.listenTo()` for model/collection events and `this.delegateEvents()` for DOM events. Ensure `View.destroy()` is called when a view is removed, and avoid direct `$(window).on()` or `Backbone.Events.on()` without corresponding `off()` calls managed by the view's lifecycle.
Ensure `backbone.marionette` is included in your project via a script tag (making `Marionette` global) or correctly imported/required via a module loader/bundler.
Verify that `backbone` is loaded before `backbone.marionette` and that `Backbone` is accessible in the scope where Marionette is loaded.
Use `import { View } from 'backbone.marionette';` (or `ItemView`, `CollectionView`, etc.) or ensure you are referencing the component correctly as `Marionette.View` if using a namespace import or global object.Ensure the DOM element specified in the `Region`'s `el` property exists in the HTML document before the Marionette Application starts or the `Region` attempts to render.