

If autoAttach is enabled, this will automatically append the view to a container. Set autoRender to true to enable rendering upon View instantiation. Chaplin provides getTemplateFunction and getTemplateData for this purpose. Your application should provide a standard way of rendering DOM nodes by creating HTML from templates and template data. Rendering: getTemplateFunction, render, … Unlike Backbone’s initialize method, Chaplin’s initialize is required to create the instance’s subviews and listen for model or collection disposal. Views must always call super from their initialize methods. Passing in options during instantiation overrides the View prototype's defaults. Options may be specific on the view class or passed to the constructor. all standard Backbone constructor options ( model, collection, el, id, className, tagName and attributes).Disposal which cleans up all subviews, model bindings and pub/sub events.Automatic rendering and appending to the DOM.Rendering model data using templates in a conventional way.) should be used, so handlers can be removed automatically on view disposal to prevent memory leakage. Instead, Backbone’s built-in methods for handling bindings, such as this.listenTo(this.model. When establishing bindings between view and model, () should not be used directly. The programatic approach of delegate solves these problems.

The declarative events hash doesn’t work well for class hierarchies when several initialize methods register their own handlers. In addition to Backbone’s events hash and the delegateEvents method, Chaplin has the delegate method to register user input handlers. Views might override the method to process the raw model data for the view. By default, this method just returns an object delegating to the model attributes. The input data for the template is provided by this.getTemplateData. The templating function is provided by this.getTemplateFunction. They have a standard render method which renders a template into the view’s root element ( this.el). Views may subscribe to global pub/sub and model/collection events in a manner which allows proper disposal. By default, all views should inherit from this class to take advantage of its additions and improved memory management. Chaplin’s View class is a highly extended and adapted subclass of Backbone.View.
