-
Notifications
You must be signed in to change notification settings - Fork 172
Basics
This section will describe getting started with LayoutManager.
You can access this class constructor either independently from Backbone or
attached to the Backbone
namespace.
var Layout = require("backbone.layoutmanager");
// Configure globally.
Layout.configure({});
// Configure globally.
Backbone.Layout.configure({});
require(["backbone.layoutmanager"], function(Layout) {
// Configure globally.
Layout.configure({});
});
Creating a new instance is easy.
// Example Layout.
var layout = new Backbone.Layout({ template: "#layout" });
If you want to differentiate between your Layouts and nested Views, you can set
the manage: true
property globally and use View
like Layout
.
// Set all Views to be managed by LayoutManager.
Backbone.Layout.configure({ manage: true });
// Example View.
var view = new Backbone.View({ template: "#view" });
When you create a new instance you can access a number of Properties and Methods.
Example of usage:
myView.insertView(".something", new SomeView()).render();
By default the Backbone.View
class constructor remains identical, except that
_configure
is patched to allow for manage: true
.
There are two ways to convert a Backbone.View
into a LayoutManager
managed View.
This is the most common way to set up a View for use with LayoutManager.
Especially useful for plugins and code that you can't switch to
Backbone.Layout
.
This method has the ability to be set globally for all Backbone.View
's. This
is a default in Backbone Boilerplate and considered a good practice.
If you set the global property and break a third party View, you can set
manage: false
on it to reverse the effect.
This method is very rarely used, but may be useful for when you are receiving a View instance and would like to convert it.
// Converts an ordinary Backbone.View into a LayoutManager managed View.
Backbone.Layout.setupView(myView);
Getting started
Usage
- Overview
- Configuration
- Basics
- Example usage
- Nested views
- Template rendering
- LayoutManager in Node.js
API reference
Migration guides
Legacy
How to contribute