Hi everyone,
I have a list of items. Each item has an input. When the user clicks enter, the record in the database should update. How can I achiev it?
Hello,
You can add this script in the OnReady event. It takes the ID of the input you want to target (in your case, the current input of the list). It adds a keydown event listener that checks if the pressed key is Enter. If true, call your update action using $actions.YourUpdateAction including any required input parameters.
how to pass the ID of each element?
In the case of a List, you won’t be able to reliably detect the widget ID. What you can do instead is add a dummy CSS class, for example .enter-input, which is bound to the list of inputs.
You can then retrieve and handle these inputs using that class in a JavaScript node.
Why not use the input class itself? To avoid overriding or affecting all inputs in the rest of the screen or the application as a whole.
Hi @Łukasz Kaproń , u can add specify class (Ex: activity-input), after that u add this JS into OnReady to handle each input on list.
Hope this is helpfull!
Huy Hoang.
Hi Lukasz,
If you want to avoid using JavaScript, you can wrap the input inside a form and add a button that triggers the action. Set the button’s Is Form Default property to True.
correct, this one is the built-in logic for the form. We are doing low-code, avoid coding all the time