in my react app (react-native-webview component) I inject a javascript snipped to update an element data fields and trigger a change event. The DOM element gets updated but the change event (homepage javascript) wont fire.
When I use the javascript snipped in the Chrome DevTools it works without problems.
_injectValue = (type, x) => {
this.webview.injectJavaScript("
var elem = document.getElementById('injectHelper');
elem.setAttribute('data-helper', "+type+");
elem.value = "+x+";
elem.dispatchEvent(new Event('change', {'bubbles':true, 'cancelable':false, 'composed':true}));
void(0);"
);
}
I tried various other methods which I found here without success: How do I programmatically force an onchange event on an input?
Is there another way or is it not possible to dispatchEvent over injectJavaScript and register it on the homepage javascript?
Cheers Hannes