BackboneJS - View


Views are used to reflect "how your data model looks like". They represent the model's data to the user. They provide the idea behind the presentation of the model's data to the user. It handles the user input events, binds events and methods, renders model or collection and interacts with the user.

The following table lists down the methods which can be used to manipulate the BackboneJS-Views.

S.No. Methods & Description
1 extend

It extends the Backbone.View class to create a custom view class.

2 initialize

It instantiates the view by using the new keyword.

3 el

It defines which element to be used as the view reference.

4 $el

It represents the jQuery object for the view's element.

5 setElement

It specifies the existing DOM element to a different DOM element.

6 attributes

They can be used as DOM element attributes on the view class.

7 $(jQuery)

It is used as a selector that contains the $ function and runs queries within the view's element.

8 template

While rendering the view, template creates reusable copies of markup and provides access to instance data.

9 render

It contains the logic for rendering a template.

10 remove

Removes a view from the DOM.

11 delegateEvents

Binds elements to the specified DOM elements with callback methods to handle events.

12 undelegateEvents

It removes delegate events from the view.