PDA

View Full Version : xtype:image handling of click event in controller



Ronits
20 Jan 2013, 10:20 PM
Hi,
Would like to have click event on xtype:'image' component. Partially solved using :
render: function(c) { c.getEl().on('click', function(e) {
Ext.Msg.alert('Pref Settings handler');
}, c);
}

HGowever, would like to handle this event in Controller. Something like :
this.control({
'image[id=preferenceSettingBtnId]': {
click: this.onPreferenceSettingBtnClick
}

But, this won't work. Any help.

mitchellsimoens
22 Jan 2013, 10:34 AM
I would create an Img extension to handle this:


Ext.define('Ux.Img', {
extend : 'Ext.Img',
xtype : 'ux-img',

onRender : function() {
this.callParent(arguments);

this.imgEl.on('click', this.onClick, this);
},

onClick : function(e, t) {
this.fireEvent('click', this, e, t);
}
});

Ronits
23 Jan 2013, 7:14 PM
Ok. Got it.

Leshicus
21 Jan 2015, 6:42 AM
In 5.1 for me it has worked, when I changed imgEl to el.