-
Notifications
You must be signed in to change notification settings - Fork 172
Events
Events are important, yet the source of mismanaged memory in Backbone applications. LayoutManager has been designed to provide you useful events and cleaning them up correctly.
There are two built in events inside of LayoutManager: beforeRender
and afterRender
.
This event is called on the View that had render
triggered on it. You must have this event bound before rendering. This is useful for modifying the state of the layout, before it is rendered. It is triggered after the beforeRender
function.
myLayout.on("beforeRender", function(view) {
// Do something to view, before rendered.
});
This event is called on the View that had render
triggered on it. You must have this event bound before rendering. This is useful for modifying the rendered contents of the layout, after it is rendered. It is triggered after the afterRender
function.
myLayout.on("afterRender", function(view) {
// Do something to view, after rendered.
});
This event is called on a View when all of its nested child Views have been removed.
myLayout.on("empty", function(view) {
// Do something to view, after all nested Views are removed.
});
Assuming you have an event-driven application designed, you'll need to ensure those events are properly cleaned up. As of Backbone 0.9.9 any events bound with listenTo
will be automatically cleaned up after calling stopListening
. LayoutManager will automatically perform this task for you at the appropriate time. It will also continue to clean up events bound with on
on the model
and collection
properties.
Getting started
Usage
- Overview
- Configuration
- Basics
- Example usage
- Nested views
- Template rendering
- LayoutManager in Node.js
API reference
Migration guides
Legacy
How to contribute