Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 141722

ReactNative Webview injectJavaScript - DispatchEvent

$
0
0

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


Viewing all articles
Browse latest Browse all 141722

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>