Backbone.js Views
- A view is just a small piece of your website.
- They organize your website's interface into logical views.
- They are meant to be re-drawn without needing to load a webpage.
- They keep you from having to refresh your page!
Attributes and Abilities
Properties
Name | Description |
el | Corresponding DOM element that represents this view. It can already exist or if not, it will be created for you. |
tagName | Specific tag that will be created for this views *el* |
className | CSS class that will be applied to this views's *el* |
id | CSS ID that will be applied to this view's *el* |
$el | A cached jQuery object for the view's element. |
attributes | A hash of attributes that will be set as HTML DOM element attributes on the view's *el* (id, class, data-properties, etc.) |
template | A template or reference to a template for use with the *render()* method |
Methods
Name | Description |
constructor | Accepts several options that will be attached to the view automatically. |
initialize() | An optional function that is called the moment a view is instantiated. |
render() | A function to render your view as HTML into the DOM. |
remove() | Removes this View from the DOM |