Skip to content

Instantly share code, notes, and snippets.

@filipmares
Created December 5, 2014 01:01
Show Gist options
  • Save filipmares/835cb18de27c0572a2a3 to your computer and use it in GitHub Desktop.
Save filipmares/835cb18de27c0572a2a3 to your computer and use it in GitHub Desktop.
LayoutView
/*
A simple task list app with standard sidebar and main area design
_______________________
| | |
|sidebar| main |
|_______|_______________|
*/
// Define a LayoutView and its Regions
var AppLayoutView = Backbone.Marionette.LayoutView.extend({
template: "#my-app-layout",
regions: {
taskList: "#side-bar",
taskDetail: "#main-content"
}
});
// Create a LayoutView
var layoutView = new AppLayoutView();
layoutView.render();
// Show a list of tasks
layoutView.taskList.show(new TasksCollectionView());
// Show task detail view
layoutView.taskDetail.show(new TaskDetailView());
// Empties Region in the DOM and also destroys view while unbinding all listeners
layoutView.content.empty()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment