Jakobovski
Jakobovski

Reputation: 3390

Angular ng-blur is being triggered on focus

I have a textarea that when one types the hash symbol "#" the focus switches to an input. The issue I am having is that when the cursor switches to the input element it is triggering the ng-blur function.

angular.element('#inputElement').focus(); is triggering a blur event.

Why is it triggering ng-blur? That makes no sense to me.

See the demo:

http://plnkr.co/edit/D3dOj90I3uQlz0OGaNjV?p=preview

Upvotes: 2

Views: 2190

Answers (2)

NFlourish
NFlourish

Reputation: 76

See the answer for this other question: ng-focus firing twice and ng-blur never fires

In short... try turning all extensions off in Chrome, and see if that makes the problem go away. The original question writer for the link above had problems because of the Angular Batarang. I personally am having problems with AdBlock... both extensions seem to be interfering with the DOM events in some manner.

Upvotes: 0

rae
rae

Reputation: 94

Sounds like a bug. The best thing you can do is set up an event that will do nothing, perhaps e.preventDefault() during blur.

Have you tried using a directive and instead of grabbing the element through angular.element("#inputElement") you use the built-in element?

Upvotes: 1

Related Questions