Reactive javascript set value of input

Hi Guru's!

When I set the value of an input by javascript in the onKeyUp event the data is not bind to the fetch from other datasource structure but it is shown in the screen.

var input = document.querySelector("#"+$parameters.InputId);
input.value = 'test';

In my screen I see the input having the value test, but when saving the structure contains the value that you typed to trigger the onKeyUp.


Hello freek,

I think this issue is related because OS change from react 15 to react 16.

Read this article: https://stackoverflow.com/questions/23892547/what-is-the-best-way-to-trigger-onchange-event-in-react-js#46012210 that I think it will solve your issue.

Hope it helps,

Nuno R

Hi Freek,

I don't find it strange that when you directly manipulate a HTML element via document.querySelector that the value isn't also set in the initial variable that was used to show the initial data on the screen. Why don't you create a Client Action that reponds on the onKeyUp event, that will then set the data in the initial variable. This will then automatically update the text on the screen.

If this does not work then please provide a demo app that shows this behavior so we can take a better look at it. 

Greetings,

Vincent

Hi Vincent,

Indeed I fixed it by creating a client action and triggering that from the JS.

But for me it's a bit strange that when I manipulate the input field that value is not being used.

Also to @Nuno Rodrigues  thnx for the help!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.