PDA

View Full Version : Id of ExtJs button firing an event



mayhem
20 Sep 2010, 2:03 PM
Hi,

I am using the following to obtain the id of the element firing the event, which is fine, but in this instance it is an ExtJs button but I get "ext-gen-54" for example. I would like the id of the button that I have provided as part of the button config.

event.srcElement.id;

//Button
var newPersonBtn = new Ext.Button(
{
id: 'newPersonBtn',
renderTo: 'new-person-div',
text: 'New person',
//etc
)};

Is this possible? I can work around it, but I thought there should be a way of obtaining the button id I specified.

Thanks for any help, and sorry if it is really simple!

evant
20 Sep 2010, 4:44 PM
The first argument of a button handler is the button object.

mayhem
21 Sep 2010, 1:13 AM
Thanks Evan.

My example was a little different as I had existing (non-ExtJs) components so needed to use the standard event model. I was able to check the id returned from event.srcElement.id and the button using

Ext.ComponentMgr.get so I could check which object was firing the event. Using this I could look up the id for my object and not the "ext-gen-54" wrapper firing the event.

Thanks for your help.