View Full Version : Ext.get() method basic

21 Nov 2012, 7:35 AM

I am using Ext.get to get an element. I am using Eclipse and Spket. In spket editor I see the get method is red in color. Also there is no autocomplete support for the variable I declared.

var exp = Ext.get('id'),

is this a correct behavior? Why there is no autocomplete for exp variable ? am I using correct Ext method ? What would be the best practice?
I think this might be more of a Spket question. any pointer would be helpful.


21 Nov 2012, 7:41 AM
if you want to get an Ext component based on its id, then you should be using Ext.getCmp('componentId'). however, using an id is discouraged. you can use componentquery to find the Ext component you want. after you get the component, you can use its methods.

21 Nov 2012, 8:23 AM
Thanks Farish, could you please site an example for using the componentquery. I am going thru a book which sites examples all using get. Kinda strange.
Scenario: if in a page I have
div1, div2,div3
and button 1,2,3
how to get access of the Ext elements.


21 Nov 2012, 8:28 AM
I am not sure what you want to do with the Ext elements/components. it could be that Ext.get() does what you need. Take a look at the API docs (http://docs.sencha.com/ext-js/4-1/#!/api/Ext-method-get) and then decide whether Ext.get() is what you want or Ext.getCmp(). you can also find info on component queries there along with examples.