Setting Focus In HTMLRenderer
2 posts
• Page 1 of 1
Setting Focus In HTMLRenderer
I'm trying to set the focus to a particular element dynamically using something like:
Which is not working for me.
It does work to use the `autofocus` attribute, but that will only work on page load:
But in a single page app I may be replacing content and then need to dynamically set the focus, so this won't do.
Any ideas? I tried putting it on a Dyalog form first, but to no avail. I'm hoping I'm just missing something obvious and we don't need a new method for the HTMLRenderer...
Focus←{
_←'hrH'⎕WC'HTMLRenderer'
h←'<input type=text id="input1">'
h,←'<input type="text" id=input2">'
hrH.HTML←h
_←hrH.ExecuteJavaScript'document.getElementById("input2").focus();'
0
}
Which is not working for me.
It does work to use the `autofocus` attribute, but that will only work on page load:
Focus2←{
_←'hrH'⎕WC'HTMLRenderer'
h←'<input type=text id="input1">'
h,←'<input type="text" id=input2" autofocus="">'
hrH.HTML←h
0
}
But in a single page app I may be replacing content and then need to dynamically set the focus, so this won't do.
Any ideas? I tried putting it on a Dyalog form first, but to no avail. I'm hoping I'm just missing something obvious and we don't need a new method for the HTMLRenderer...
- paulmansour
- Posts: 430
- Joined: Fri Oct 03, 2008 4:14 pm
Re: Setting Focus In HTMLRenderer
Ok, the above example was bad HTML (missing a double quote), but that's not the problem. The browser needs a moment to do whatever it does. So this works:
Problem solved, I think.
FocusExample1←{
_←'hrH'⎕WC'HTMLRenderer'
h←'<input type=text id="input1">'
h,←'<input type="text" id="input2">'
hrH.HTML←h
_←⎕DL 0.1
_←hrH.ExecuteJavaScript'document.getElementById("input2").focus()'
0
}
Problem solved, I think.
- paulmansour
- Posts: 430
- Joined: Fri Oct 03, 2008 4:14 pm
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group