Prevent button action from running on load? #884
Answered
by
mbostock
gouldingken
asked this question in
Q&A
-
I'm looking to use a button to set an input value when clicked. How do I ensure that button code is run when I click the button, but not on load? I tried adding const resetButton = view(Inputs.button("Reset")); resetButton;
inputControl.value = 222; |
Beta Was this translation helpful? Give feedback.
Answered by
mbostock
Feb 20, 2024
Replies: 1 comment 1 reply
-
Set the required option to true. const reset = view(Inputs.button("Reset", {required: true})); This sets the initial value to undefined which will prevent the generator from resolving until the button is clicked, such that any code block referencing |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
gouldingken
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Set the required option to true.
This sets the initial value to undefined which will prevent the generator from resolving until the button is clicked, such that any code block referencing
reset
likewise will not until click.