PDA

View Full Version : Event Trouble



tmanderson
19 Jan 2011, 1:12 PM
Hey everyone!

I have a custom panel that I am trying to make fire the addedEvent 'listselected' I've verified that internally it is running the function that fires the event on item disclosure, but it doesn't seem like my controller is catching the supposed fired event.

Here's the panel firing the event:


ListMe.views.HomeMenu = Ext.extend(Ext.Panel, {

initComponent: function() {

this.addEvents({
'listselected': true
});

this.list = {
xtype: 'list',
store: 'Lists',
itemTpl: '{name}',
disableSelection: true,
onItemDisclosure: this.listSelected
}

this.items = [this.list];
this.layout = 'fit';

ListMe.views.HomeMenu.superclass.initComponent.apply(this, arguments);
},

listSelected: function() {

this.fireEvent('listselected');
}
});

Ext.reg('homemenu', ListMe.views.HomeMenu);


and the controller that's supposed to catch it:


Ext.regController('Main', {

home: function() {

this.viewport = Ext.getCmp(this.application.defaultTarget);

this.homeMenu = {
id: 'homeMenu',
xtype: 'homemenu',
listeners: {
listselected: this.list
}
};

this.render(this.homeMenu);
},

list: function() {
console.log('homeMenu fired a listselected event!');
}
});


I've even accessed the component via my console and fired the event and the controller caught it then...

Thanks in advance!

tmanderson
19 Jan 2011, 1:40 PM
Well, the documentation states that when setting a value for a list's onItemDisclosure parameter that you can supply it with an object containing the handler and the scope:


onItemDisclosure: {
handler: this.listSelected,
scope: this
}


Turns out the 'scope' parameter doesn't fully work, so I had to dig into the list object when the event actually fired, like so:


this.onItemDisclosure.scope.fireEvent('listselected');


It's working just fine now. I'll post this as a bug.