module 11 - forms Flashcards

1
Q

how do you stop a button from submitting a form?

A

You listen on the form to the submit even and prevent it while calling another method. @submit.prevent=”another method”

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

what does @input do?

A

@input is a shorthand for the call v-on:input=”inputHandler” which is triggered on every key stroke

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

Will there be a difference between retrieving the value on an input with type=number using v-model vs. ref

A

When you use v-model you will get a number back. when you use ref you will get a string back. if you entered 5 and you do +4 to the value. the one retrieved with v-model will become 9 while the one retrieved by ref will become 54

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

what does v-model.lazy do?

A

if we don’t set this modifier the data will be updated on every key stroke. if we do set it then the value will be updated on a lower frequency.

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

what does v-model.trim do?

A

it removes white spaces before and after the value in the input.

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

how to connect a list of checkbox’s with v-model

A

the value in data backing the checkbox list needs to be an array and not just a single field. Each checkbox should have the same name and a different value which is what is going to be stored in the array

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

how to connect a list of radio buttons with v-model

A

Each radio button should have the same name and a different value which is what is going to be stored in the array

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

How do you connect a single checkbox with v-model

A

in case of a single checkbox we connect the v-model to a single field and the values there will be true/false

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

What happens if I give a button a type of button

A

Giving a button in a form a type of button revokes its default behavior of submitting the form.

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

what prop does v-model set on a custom component?

A

The prop is “modelValue”

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

what event is v-model listening to on a custom component?

A

The event that the custom component needs to emit in order to work with v-model is “update:modelValue”

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