1331
Views
3
Comments
Solved
Setting focus to an Input on Reactive App

Hi guys!

I need some help with setting the focus to an input field in a Reactive app. I want to set the focus to a specified input during a Client action. I could not find an equivalent for the Input_SetFocus action, so I tried using using a JavaScript action, but I cannot seem to get the syntax right... I am trying to use something like:

"$(""#" + SpecifiedInput.Id + """).focus()"

However this does not seem to be working... I suspect my syntax is broken, but none of the variations I have tried work.

Any advice / pointers would be appreciated!

2019-09-30 07-35-56
Aurelio Junior
Solution

Also, I see that you're using jQuery for that. If you already have it in your app, then that's fine. Otherwise, it might be overkill to add it just to accomplish this. You could do it with plain javascript with something like:

document.getElementById($parameters.InputId).focus();
2019-09-30 07-35-56
Aurelio Junior

Hi Chris,

Yes, your syntax is incorrect. This is pure javascript code, so there's no need to wrap it in double quotes (""). Also, you need to pass in the input's Id as a parameter to the javascript block.

2019-09-30 07-35-56
Aurelio Junior
Solution

Also, I see that you're using jQuery for that. If you already have it in your app, then that's fine. Otherwise, it might be overkill to add it just to accomplish this. You could do it with plain javascript with something like:

document.getElementById($parameters.InputId).focus();
2019-08-21 11-19-08
Chris Vorster

Thanks Aurelio!

The plain JavaScript worked perfectly!

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