import * as Backbone from 'backbone'; // Example code. class DisplayView extends Backbone.View { constructor(options?: Backbone.ViewOptions) { super(options); this.manage = true; this.template = "#display"; } manage: boolean; template: string; } // Create a View to be used with the Layout below. class View extends Backbone.Layout { constructor(options?: Backbone.LayoutOptions) { super(options); this.template = "#view"; // When you click the View contents, it will wrap them in a bold tag. this.events = { "click": "wrapElement", "mouseenter": "insertElement", "mouseleave": "removeElement" } } wrapElement(): void { this.$el.wrap(""); } insertElement(): void { this.insertView(new DisplayView()).render(); } removeElement(): void { // Removes the inserted DisplayView. this.removeView(""); } } // Create a new Layout. var layout = new Backbone.Layout({ // Attach the Layout to the main container. el: ".main", // Use the previous defined template. template: "#layout", // Declaratively bind a nested View to the Layout. views: { "p": new View() } }); // Render the Layout. layout.render();