I have an input box, and I want to filter the input. In the On Change event handler, I have logic to set a Page Data property to the value I want.
This is a simplified example -
The value logic gets the value from the Page Data variable -
The On Change logic updates the Page Data property, and the value logic runs (see prints below), but the input value doesn’t change -
Why isn’t the value of the input box getting overwritten?
This is what I got:
The value is overwritten. The only difference is the
Value Logic uses databinding:
Changing the value logic to databinding also worked for me. I didn’t think there was a difference between databinding and codeless logic. Have you made a video that describes the difference?
I believe the difference is in the timing when it is executed. You change the underlying data model in the
On Change event. That change triggers a re-render of the UI, this is when all bindable properties are re-evaluated.
If you have logic for a property it occurs at a different timing than if you have pure data binding. I am not entirely clear when exactly it happens, but it clearly has an impact on the execution. This is something @vladimir-upirov can clarify.
Would you recommend using data binding over codeless to assign values to inputs, etc.? I have been using codeless to keep things consistent, but this issue has me re-thinking.
You are welcome, Tim. If the data comes straight from the data model, use plain data binding every time. However, keep in mind that the data binding is bi-directional. So if you have a mapping in place, it will work for both updating the data model from the UI component and updating the UI component from the data model.
That is interesting. Am I understanding you correctly that by data binding the value logic of an input, any changes to the input from the UI will change the data model? What happens if there is logic in On Change? Does On Change run after the data binding, updating the data model again?
We explain it in the docs (I am sure I described it in multiple videos too):
That logic runs only when the value of the input is changed by the user.
Have a great holiday weekend!