PDA

View Full Version : add event click to label



asics167
27 Nov 2013, 10:20 PM
Hello!
i can add event click to label?
i write this test window with Label and add event onclick on afterrender..
but event click not fire..

Ext.define('MyApp.view.MyWindow', {
extend: 'Ext.window.Window',

height: 472,
hidden: false,
width: 799,
title: 'My Window',

initComponent: function() {
var me = this;

Ext.applyIf(me, {
items: [
{
xtype: 'label',
id: 'labelid',
itemId: 'labelitemid',
text: 'My Label',
listeners: {
afterrender: {
fn: me.onLabelAfterRender,
scope: me
}
}
}
]
});

me.callParent(arguments);
},

onLabelAfterRender: function(component, eOpts) {
var label = component;
label.on("click", function () {
console.log('click', this);
alert(this.text); },
label);
console.log(label);
}

});

asics167
28 Nov 2013, 1:17 AM
this work for me - add .getEl() in set event

label.getEl().on("click", function () {

Gary Schlosberg
29 Nov 2013, 4:46 PM
Glad you found something that works, and thanks for taking the time to post the follow-up.