Views Flashcards
(20 cards)
true/false Backbone views are used to tie models to the document.
TRUE
Do views handle dom events or model events?
both
How do you create views?
Extend Backbone.View Backbone.View.extend({});
What associated DOM element do views have at all times?
.el
How is a view defined?
It’s defined by the following…
Backbone.View.extend({ tagName: 'li', id: 'anything-you-want', className: 'hello-world', attributes: { 'data-value': 'hello' } });
How do you instantiate a view?
Views are instantiated by calling the constructor with the “new” keyword.
What’s the simplest example of instantiating a Backbone View?
new Backbone.View();
What will you normally pass to a view’s constructor?
a model
What does el reference?
The views DOM element
What is $el?
A cached jQuery wrapper around el
true/false $el is not cached
false
true/false Render is not a function that render’s the views element(.el)
false
What should render usually return?
this
How do you pass a model to a view?
Through the views constructor?
What are the 3 arguments to the make method?
Element to make, attributes to set on the element, and the value of the element.
How do you remove a View from the dom?
var v = new Backbone.View();
v.remove(); Just like jQueries remove basically.
What is the declarative syntax to registering event handlers?
var FormView = Backbone.View.extend({ events: { 'click .clickable': 'handleClick' or function() { blah } }, handleClick: function() {
} });
JQUERY
this.$(‘.clickable’).click(handleClick);
Should you ever manipulate DOM elements that are not self-contained by the view?
no
true/false - You should access DOM elements that the view does not own?
FALSE
true/false - You should always pass the el to the constructor or self-updating view and not in the view iteslf.
TRUE