how to set focus on a freshly created element of list of text inputs
Application Type
Reactive
Service Studio Version
11.10.15 (Build 40206)

I need to set focus on the last element of a list of text inputs, when I create a new input (the last one). 


I tried to use Javascript for this, but I don't know the element Id. Using Chrome Inspector I found an Id in the list, but it doesn't work for the last element of the list, just for the already created ones. Also, I'd like to use setFocus() method from Outsystems UI.

mvp_badge
MVP

Hi skylucacius,


You can give the inputs a class and use Javascript to get the element id of the last input with that class as an output and use that id as an input for your setFocus action.


If you give the inputs a class "my-input", something like the code below would get you the widget id of the last element with this class:

document.querySelectorAll(".my-input:last-child")[0].id

 

Kind Regards,
João

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.