0

I'm working on a chrome extension which I'd like to automatically fill in some forms on a specific web application. The web application uses angular.js and each input has a blur event which validates the values (ng-blur="validateValue(input)").

I can get the value in the inputs but for the web application to actually receive them the validateValue method has to be triggered.

Is there any way that I can trigger the ng-blur through my extension?

I've tried: - calling the blur method (both native and jquery). - calling focus before calling blur

  • In the content script inject a ` – wOxxOm Nov 30 '15 at 11:43
  • I'm trying to. Triggering the event however proves difficult =( – Peter Panda Nov 30 '15 at 23:02
  • On the other hand, maybe simply *blur* it like `someInputElement.blur()`? Or focus another element or document.body? – wOxxOm Nov 30 '15 at 23:07
  • @wOxxOm I've tried.. it doesn't trigger the event handlers that have been added to it by the web application :( – Peter Panda Dec 01 '15 at 11:51

1 Answers1

1

Solution:

I also faced the same issue while developing chrome extension which scraps an angular website. I have wasted many days in search for the solution.

Good news is that I found the solution that worked for me.

Create an event with input & followed by blur event. Dispatch these event in the same order. eg.

elem.dispatchEvent(new Event('input'));
elem.dispatchEvent(new Event('blur'));

This will trigger ng-blur="validateValue(input)".