Views Flashcards

1
Q

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

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Do views handle dom events or model events?

A

both

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you create views?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What associated DOM element do views have at all times?

A

.el

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How is a view defined?

A

It’s defined by the following…

Backbone.View.extend({
    tagName: 'li',
    id: 'anything-you-want',
    className: 'hello-world',
    attributes: {
        'data-value': 'hello'
    }
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you instantiate a view?

A

Views are instantiated by calling the constructor with the “new” keyword.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

new Backbone.View();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

a model

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does el reference?

A

The views DOM element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is $el?

A

A cached jQuery wrapper around el

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

true/false $el is not cached

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What should render usually return?

A

this

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you pass a model to a view?

A

Through the views constructor?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the 3 arguments to the make method?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you remove a View from the dom?

A

var v = new Backbone.View();

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

17
Q

What is the declarative syntax to registering event handlers?

A
var FormView = Backbone.View.extend({
    events: {
        'click .clickable': 'handleClick' or function() { blah }
    },
    handleClick: function() {
} });

JQUERY
this.$(‘.clickable’).click(handleClick);

18
Q

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

A

no

19
Q

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

A

FALSE

20
Q

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

A

TRUE