admin管理员组文章数量:1403187
I have trivial window:
this.window = Ext.widget('window', {
title: 'Find',
closeAction: 'hide',
width: 300,
layout: 'fit',
items: form
});
with trivial form in it
var form = Ext.widget('form', {
layout: {
type: 'vbox',
align: 'stretch'
},
border: false,
bodyPadding: 10,
items: [
this.findInput,
]
});
which only has one item
this.findInput = Ext.widget('textfield', {
name: 'find'
});
The issue is: how to set focus right after window is shown? I tried to call .focus()
method of this.findInput
in almost every window event handler with no luck.
Seems like even afterrender
is called synchronously before DOM has created all the elements pletely.
What have I missed? What event should I bind to to have all the elements rendered and able to accept the focus?
PS: if I call the same .focus()
after small interval like 10ms - I get it focused, but it's not a solution
I have trivial window:
this.window = Ext.widget('window', {
title: 'Find',
closeAction: 'hide',
width: 300,
layout: 'fit',
items: form
});
with trivial form in it
var form = Ext.widget('form', {
layout: {
type: 'vbox',
align: 'stretch'
},
border: false,
bodyPadding: 10,
items: [
this.findInput,
]
});
which only has one item
this.findInput = Ext.widget('textfield', {
name: 'find'
});
The issue is: how to set focus right after window is shown? I tried to call .focus()
method of this.findInput
in almost every window event handler with no luck.
Seems like even afterrender
is called synchronously before DOM has created all the elements pletely.
What have I missed? What event should I bind to to have all the elements rendered and able to accept the focus?
PS: if I call the same .focus()
after small interval like 10ms - I get it focused, but it's not a solution
- See also Set focus on Extjs textfield – Vadzim Commented Feb 26, 2018 at 14:19
1 Answer
Reset to default 6Check out activeItem
property - http://docs.sencha./ext-js/4-0/#!/api/Ext.form.Panel-cfg-activeItem
or you can also use defaultFocus
: http://docs.sencha./ext-js/4-0/#!/api/Ext.window.Window-cfg-defaultFocus
本文标签: javascriptSet focus for text input in just created windowStack Overflow
版权声明:本文标题:javascript - Set focus for text input in just created window - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744387474a2603814.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论