问题
Say the component doesnt have an ID given to it. So how would you first, get a handle on the component, and then get the DOM Id of that component?
thanks in advance!
-Jack
回答1:
Use the javascript console. You can also install FireBug.
In your javascript code put:
console.log(myComponentWhosIdIWantToGet);
Explore you object's properties.
回答2:
I believe this is what you need: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.Component-method-getEl
Example:
//get Dom Element
var DomEl = Ext.getCmp('ComponentID').getEl();
//get Id
var DomElId = DomEl.id;
回答3:
You can use this (not so many distinctions from answer of Meister but anyway):
var DomEl = Ext.getCmp('ComponentID').getEl().dom.id;
来源:https://stackoverflow.com/questions/20253834/extjs-how-to-get-dom-id-of-a-component