Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add Click Event to Ext.Img?

How can I add Click Event to Ext.Img?

var paddleItem = new Ext.Img({
    xtype : 'image',
    src : "lib/Image/Paddle.png",
    x : 200,
    y : 300,
    draggable : true,
    index : 0,
    id : 'paddleItem',
    listeners : {
        click : function(){
            Ext.Msg.alert("Message");
        }
    },
    renderTo : Ext.getBody()
});

This is My Code, but it didn't Work.

Please Get me some Advice..

like image 827
LostCode Avatar asked Mar 12 '12 09:03

LostCode


1 Answers

Bind it on the underlying element:

var paddleItem = new Ext.Img({
    src: "lib/Image/Paddle.png",
    x: 200,
    y: 300,
    draggable: true,
    index: 0,
    id: 'paddleItem',
    listeners: {
        el: {
            click: function() {
                Ext.Msg.alert("Message");
            }
        }
    },
    renderTo: Ext.getBody()
});
like image 183
Evan Trimboli Avatar answered Sep 20 '22 13:09

Evan Trimboli