How to set focus to a textbox that was just inserting it into my page?
-
27-09-2019 - |
Question
I have a dynamic web page that after clicking a link, I insert a partial view into my page using brailjs action. My brailjs view looks like this
page.inserthtml('bottom', 'items', { @partial: 'item/_fields_replacement_part' })
page.replacehtml('add_item_link', { @partial: 'item/_addlink_replacement_part' })
After I insert the html, I want to be able set focus to one of the textboxes that was just inserted. How can I do that?
Solution
Say you have this js function:
function setFocus(id) {
document.getElementById(id).focus();
}
You can call it from brailjs like this:
page.call('setFocus', 'myElementId');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow