0

Given a component like this:

{xtype: 'textfield', name: 'title', fieldLabel: 'Title', autoFocus: true}

Is it possible to query for all items in an arbitary container (say a window) that have an attribute autoFocus to call the method .focus(...) on it?

Tried...

'[autoFocus]'

'*[autoFocus]'

'*[autoFocus=true]'

...with component.down and Ext.ComponentQuery.query (and others), but no luck.

Tarabass
  • 3,132
  • 2
  • 17
  • 35
Ron
  • 1,336
  • 12
  • 20

1 Answers1

3

Ext.ComponentQuery.query('textfield[autoFocus]') should work, provided that the textfield is instantiated.

Saki
  • 5,827
  • 2
  • 15
  • 15
  • Ok, I found a solution. The query itself is not the problem! It works as it should. If I query for components in the window's initComponent() method (after this.callParent(arguments)), the component could not be found for some reason. [If I hook myself into the 'show'-event](https://gist.github.com/rkrx/2ddf72aa04765ae262fd), the `.focus()` operation works. – Ron Jun 03 '14 at 07:54
  • Yeah, during `initComponent` they may not be instantiated yet. – Saki Jun 03 '14 at 11:02