-
I'm just getting started with re-com so it is entirely possible that this is the wrong way to do things, but given the following code:
...which produces an input-text followed by a button, the button will clear the text as expected until the first character is entered into the text box by hand. Then the clear button stops working. What is the correct way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The The value it returns to the This allows you to have full control of what goes into your atom. It also means you have to reset! your atom to the new value for the change to take effect. So, simply add a (reset! text-model %) inside the For further clarity (I hope), the reason it works the first time is because the Clear button DOES reset! YOUR atom, but your atom then remains empty after that. |
Beta Was this translation helpful? Give feedback.
-
Aha! Thanks |
Beta Was this translation helpful? Give feedback.
The
input-text
component takes the:model
you pass it (can be a value or an atom) and copies the value into its own internal atom and uses that from then on.The value it returns to the
:on-change
event is the new value of its internal atom. It does not change your atom in any way.This allows you to have full control of what goes into your atom. It also means you have to reset! your atom to the new value for the change to take effect.
So, simply add a (reset! text-model %) inside the
:on-change
function and it should do what you want.For further clarity (I hope), the reason it works the first time is because the Clear button DOES reset! YOUR atom, but your atom then remains empty after …