3.0.0

Input Control Setting Focus

Hi,
I have an input control, in a HTML span like this:

var container = new AW.HTML.SPAN;
document.write(container);

var obj = new AW.UI.Input;
obj.setId('id');
obj.onControlValidated = function(text) {
if (window.event.type == "keydown" && window.event.keyCode == 13){
//do something
}
}
var obj1 = new AW.UI.Label;
obj.setId('id1');

var contents = [obj, obj1];

container.element().innerHTML = contents.join("");
var tag_id = obj.getTag();
alert(tag_id);

The span (container), also contains more elements inside, which are drawn at runtime.

My problem, is with setting focus to the input control. onControlValidated() gets fired, only for the first time, when I enter some data in the Input control and press Enter. Based on the input value, it draws additional controls, inside the span.
Then the focus gets lost. I tried to get the focus on the input control, with no luck.

When I tried to get the tag for the input control, it gives me 'span', instead of 'input'.
var tag_id = obj.getTag();
alert(tag_id);

So can you please help me, in how to get the focus back on input control, and how to get the event fired (onControlValidated()), everytime.

Thanks
VJ
March 31,
Forgot one point.
But when I use document.write(obj), then I get the focus back on the input control, but when I use with span and innerHTML, I could not get the focus on the control.

Thanks
VJ
March 31,
You can use focus() method -

obj.focus();
Alex (ActiveWidgets)
April 3,
Thanks Alex, it works now.
VJ
April 16,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.