javascriptextjsdom-eventsjavascript-framework

How to add click event on Extjs 4 label


I try to add click event on label in extjs4 but not working

Ext.onReady(function() {

    var ResetLabel = new Ext.form.Label({
        id:'ResetLabel',
        text: 'click it',
        renderTo : document.body                                

    });
    alert(Ext.getCmp('ResetLabel').id);

    Ext.getCmp('ResetLabel').on('click',function(){

        alert("message");
    });

});

How to add event on a label?


Solution

  • this code is working in Extjs 4

    Ext.onReady(function() {
    
        var ResetLabel = new Ext.form.Label({
            id:'ResetLabel',
            text: 'click it',
            renderTo : document.body                                
    
        });
        alert(Ext.getCmp('ResetLabel').getEl());
    
        Ext.getCmp('ResetLabel').getEl().on('click',function(){
    
            alert("message");
        });
    
    });