dashman
dashman

Reputation: 3028

Nativescript - TextField lose-focus event

In {N}, I've got a TextField and would like to call a function when the focus is lost.

I've looked at the returnPress event - but that doesn't seem to be invoked on losing focus.

I've got text="{{ property }}" set - it gets called on every key input. I just need it at the end of the input.

Upvotes: 3

Views: 3236

Answers (2)

Eddy Verbruggen
Eddy Verbruggen

Reputation: 3550

A little while ago I added the blur event so you can now do blur="{{ onBlur }}" or (blur)="onBlur()" in case you're working on an Angular app.

And just so you know, there's currently a PR pending to add the focus as well.

Both of these are/will be available for TextField and TextView.

Upvotes: 3

Dlucidone
Dlucidone

Reputation: 1101

Here how you can envoke function as soon as you press the return key from keyboard -

<TextField #secondTx hint="Phone*" row="1" colspan="4" autocorrect="false" returnKeyType="done" (returnPress)="YourFunction(secondTx.text)" [(ngModel)]="phoneNumber" keyboardType="phone" ></TextField>

Let me know if it doesn't work! Thanks

Upvotes: 0

Related Questions