M
M
Mikhail Beloshitsky2017-01-10 23:04:18
JavaScript
Mikhail Beloshitsky, 2017-01-10 23:04:18

How not to update the value of an input on user input?

There are projects on vue.js, in some of them not everything goes smoothly with databinding.
It's good when it is unidirectional - from the input fields, the data is transferred to the state and then spread throughout the application.
But there are a number of cases when it is more convenient to use two-way data binding - that is, data can be transferred both from input fields and received back into them (for example, a validator works, initialization of fields with initial values, or something similar). In such situations, it is important not to update the data in the input field when the user is engaged in it, otherwise his rage is guaranteed.
Maybe someone knows if there is any standard feature in angular or vue to block field updates on user input into them? Of course, I will write my own, but lazily.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mikhail Beloshitsky, 2017-03-04
@mbeloshitsky

In OpenLecture video #2017.1 - Let's Vue! found the answer - modifiers are used for this. The modifier is suitable for my question .lazy.

<!-- synced after "change" instead of "input" -->
<input v-model.lazy="msg" >

Documentation .

N
Nicholas, 2017-01-10
@healqq

In angular, you can put in ng-model-options, for example, an update only with blur. Well, use parsers / formatters for validators and other things.

D
dmz9, 2017-01-10
@dmz9

those. while the input is in focus - do not apply the validator, but as soon as the focus is lost - apply?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question