Fork me on GitHub
#re-frame
<
2021-10-24
>
DFST16:10:06

I'm working on an app where the user can create several text input areas. I would like to make it so that an event will be triggered when the user presses the 'enter' key, but the event needs to trigger effects that depend on which dynamically created text area they were typing in. I'm at a loss of how to do that in a re-frame way. Would really appreciate a suggestion or two on how to accomplish this. Thanks.

p-himik16:10:40

Three approaches: • Handle Enter key press on a per input basis and just add an argument to the relevant event vector that would identify that input field • Handle Enter key press on a form basis but have an atom that stores currently focused input's ID (just as above, it doesn't have to be HTML ID attribute - just something to distinguish the inputs in your app's logic) • Same as above, but instead of a separate atom use some path in re-frame's app-db. Would make sense if you consider the information on the currently focused input as a part of your app's state

DFST19:10:44

Thank you for the quick response! I will give #3 a shot.

👍 1