A
A
Alexey Yarkov2016-03-12 14:10:23
JavaScript
Alexey Yarkov, 2016-03-12 14:10:23

What's wrong with onblur?

DEMO
Add an element to the list, and then click for example on the login and remove all text from the input.
And click anywhere on the page. What will happen?
The idea is to auto-save the old value if the field has been cleared. But onblur does not always work. If you clear the input and click on another input or on another element to edit, the values ​​are restored. And if it's just on the page, then no.
Thus event, judging by lines in the console works.
I xs, I've been fighting for 2 hours already ...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Yarkov, 2016-03-12
@yarkov

The decision, as usual, came after smoking the documentation ))
I added the ng-blur="restore()" directive to the input, and in the restore() method I restore the old value.
Perhaps a crutch, but such a solid, strong))

P
Pavel Volintsev, 2016-03-12
@copist

onchange or onkeyup will probably be more reliable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question