PDA

View Full Version : Ex.Component: pass element ID on click event (MVC)



sir_holmes
25 Mar 2012, 5:54 AM
Hey,

I made an Ext.Component clickable by adding a listener. This works fine. But it does not pass the ID of the component... when I want to access c.id in the controller the console says 'undefined'. Does anybody have an idea about that? Thanks!


View:
Ext.define('carabids.view.basic.siteNavigationElement' ,{
extend: 'Ext.Component',
alias : 'widget.siteNavigationElement',
renderTo: Ext.get('upperBarLeftSideLinks'),

initComponent: function(){
var me = this;
me.callParent(arguments);
},
listeners: {
render: function(c) {
c.getEl().on('click', function(){ this.fireEvent('click'); }, c);
}
}
});


Controller:
init: function() {
Ext.create('widget.siteNavigationElement',{html: langNavi[0], id: 'myButton', componentCls: 'siteNavigationLink'});

this.control({
'siteNavigationElement': {
click: function(c){
console.log(c.id);
}
}
});
},

mitchellsimoens
25 Mar 2012, 6:40 AM
fireEvent takes arguments:


this.fireEvent('click', this, e);

Where this and e are not arguments that will be accessible for event listeners.