Views Flashcards Preview

Backbone > Views > Flashcards

Flashcards in Views Deck (20):
1

true/false Backbone views are used to tie models to the document.

TRUE

2

Do views handle dom events or model events?

both

3

How do you create views?

Extend Backbone.View Backbone.View.extend({});

4

What associated DOM element do views have at all times?

.el

5

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'
}
});

6

How do you instantiate a view?

Views are instantiated by calling the constructor with the "new" keyword.

7

What's the simplest example of instantiating a Backbone View?

new Backbone.View();

8

What will you normally pass to a view's constructor?

a model

9

What does el reference?

The views DOM element

10

What is $el?

A cached jQuery wrapper around el

11

true/false $el is not cached

false

12

true/false Render is not a function that render's the views element(.el)

false

13

What should render usually return?

this

14

How do you pass a model to a view?

Through the views constructor?

15

What are the 3 arguments to the make method?

Element to make, attributes to set on the element, and the value of the element.

16

How do you remove a View from the dom?

var v = new Backbone.View();

v.remove(); Just like jQueries remove basically.

17

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);

18

Should you ever manipulate DOM elements that are not self-contained by the view?

no

19

true/false - You should access DOM elements that the view does not own?

FALSE

20

true/false - You should always pass the el to the constructor or self-updating view and not in the view iteslf.

TRUE