PDA

View Full Version : replacing text in an item of a vbox of a panel detecting dynamically the clicked item



javismiles
22 Jul 2011, 11:17 PM
I create a panel with a vbox that has 3 items: red,amber and green
then i set a click event, and when that event is triggered, i want to change the text
of the item i clicked.
problem is i dont know how to detect from inside the click event the id of the item that was clicked and how to access it to change its text
I know it works if i hardcode it like this

Ext.getCmp('red').body.update(simpleHTML, true);

but what should i replace 'red' with, so that it automatically replaces the item you clicked?
i just dont know how to get the id (red, amber or green) of the clicked item

rootPanel=new Ext.Panel({
fullscreen: true,
id: "panelito",
layout: {
type: "vbox",
align: "stretch",
pack: "end"
},
defaults:{flex:1},
items: [red,amber,green],
dockedItems: [toolbar],
listeners: {
afterrender: function(c){
c.el.on('click', function(ev,target){var target = ev.getTarget() ;
var simpleHTML = "<B>This works</B>";
Ext.getCmp('red').body.update(simpleHTML, true);

});
}
}

});