1

I'm making a UserScript to change an Angular ReactiveForm inputs values (as a development tool) ; I'm using the old classic :

$('myinput').val('myVal')

It's working great, all my inputs have a value but Angular doesn't detect the changes so I've tried to trigger the change event (I even tried keyup, dow, focus... with jQuery & native JavaScript dispatchEvent) :

trigger('change') // on each inputs & on the form

But my ReactiveForm doesn't update its values, how can I perform this task?

  • Could you please show more code on your implementation. Just curious though? why mix jQuery with Angular? :-/ ? – Chif Nov 29 '19 at 15:56
  • Why? When you can do this with angular? – penleychan Nov 29 '19 at 15:56
  • It's to have a button (keydown event) to log in automatically on localhost. – Geoffrey Migliacci Nov 29 '19 at 15:58
  • You may have to trigger the native event handler, rather than having jQuery generating the event. jQuery doesn't necessarily trigger events attached outside of its pervue. Example: https://jsfiddle.net/d59o14gf/1/ – Taplar Nov 29 '19 at 15:59
  • Still don't need jquery for that you can trigger the keydown with angular event. I suggest you look into angular documentations. – penleychan Nov 29 '19 at 16:02
  • @penleychan you can do that from a userscript? – Taplar Nov 29 '19 at 16:16
  • I know, the thing is that it's for the development environment only & it contains sensitive data (mail & password). That's why I want to make a UserScript. – Geoffrey Migliacci Nov 29 '19 at 16:17
  • @Myerffoeg This question addresses dispatching a native event handler. I'd give that a try. https://stackoverflow.com/questions/2490825/how-to-trigger-event-in-javascript – Taplar Nov 29 '19 at 16:18

0 Answers0