Set the focus to enter the text of the window just created

I have a trivial window:

this.window = Ext.widget('window', { title: 'Find', closeAction: 'hide', width: 300, layout: 'fit', items: form }); 

with a trivial form in it

 var form = Ext.widget('form', { layout: { type: 'vbox', align: 'stretch' }, border: false, bodyPadding: 10, items: [ this.findInput, ] }); 

which has only one element

  this.findInput = Ext.widget('textfield', { name: 'find' }); 

The problem is this: how to set the focus right after the window is displayed? I tried calling the .focus() method of .focus() in almost every window event handler with no luck.

It seems that even afterrender is called synchronously before the DOM has fully created all the elements.

What did I miss? What event should I bind to ensure that all elements are displayed and can take focus?

PS: if I call the same .focus() after a short interval like 10 ms - I get it focused, but this is not a solution

+4
source share

All Articles