PDA

View Full Version : Label click event ?



dekely
26 Aug 2010, 3:36 AM
Hi All,
Is it possible to add a mouse click event to a label? I don't see the option in the documentation but
I thought maybe someone has an idea.
Basically what I'm trying to do is to create an html text(even a button with no background - is it possible ?) with click even.

Thanks

dekely
26 Aug 2010, 3:55 AM
SOLVED



var lbl = new Ext.BoxComponent({
id: i,
autoEl: {
html: '<u><font color="'+color+'" size="'+size+'">'+topic.topic+'</font></u>&nbsp;&nbsp;'
},
listeners : {
render : function(c) {
c.getEl().on('click', function() {
alert("OK");
});
}
}
});

fabio.parra
26 Aug 2010, 5:07 AM
After field is rendered you can call method getLabelEl and attach a listener



var field = new Ext.form.DateField({
width : 200,
fieldLabel : 'Data',
listeners : {
afterrender : function(field){
var el = field.getLabelEl();
if(el){
el.on("click",function(){
console.log(arguments);
});
}
}
}
});
var panel = new Ext.Panel({
layout : 'form',
items : field,
renderTo : Ext.getBody()
});