Hello,
I'm building a block to be reused has a library for other application.
The goal of this block is to search for specific HTML elements (like inputs, buttons, links) and perform actions on them (like click, change value).
I was able to make it work however, it does not work as expected for the case of changing the value of inputs. The input changes indeed but the variable bind to the input does not change, impacting any action afterwards like saving or submitting a form.
I know that the two are separate things but I really need to have a way to make this work considering that I cannot refer to specific variable hard-coded (this block is to be used by any page so the variables depend on the page). I've already find a way to do this in react using the "useState" but I don't know how to use this in OutSystems javascript.
The solution must be applied only to the block, without the need to change the way the screens are developed, so that it can be reused for any application.
Can anyone help here?
Thanks.
I was able to solve the issue using the following javascript:
// Get the React setter for input elements // const nativeInputValueSetter = Object.getOwnPropertyDescriptor( window.HTMLInputElement.prototype, 'value').set;
// Invoke the setter on the input element with the new value // nativeInputValueSetter.call(element, $parameters.Value);
// Create a new onchange event //const event = new Event('change', { bubbles: true });
// Dispatch the event //element.dispatchEvent(event);