PDA

View Full Version : 4.2.1 MVC issue: controller catching another views' events



drunkmoose
6 Jun 2014, 12:46 PM
49263I have this weird issue with ExtJS 4.2.1.


I have a controller whose listeners catch events from a view that it shouldn't.


Here's said controller:


Ext.define('Customer_Portal_UI.controller.NavigationMenu', {
extend: 'Ext.app.Controller',
init: function () {
this.control({
'panel': {
render: function (panel) {
panel.body.on('click', function (panel, e) {
alert('onclick');
});
}
}




});


}
});

It 'controls' this view:


Ext.define('Customer_Portal_UI.view.NavigationMenu', {
extend: 'Ext.form.Panel',
alias: 'widget.navigationmenu',
region: 'west',
layout: 'fit',
ui: 'cssmenu',
loader: {
autoLoad: true,
url: '/resources/notloggedin.html'
}


});





But it also catches panel clicks from this view:




Ext.define("Customer_Portal_UI.view.MainContent", {
extend: 'Ext.form.Panel',
alias: 'widget.maincontent',
region: 'center',
layout: 'card',
border: false,
activeItem: 0,
requires: ['Ext.grid.Panel'],
initComponent: function () {


this.items = [
{
xtype: 'panel',
title: ''
},
{
xtype: 'gridpanel',
id: 'contactlistgrid',
store: Ext.data.StoreManager.lookup('contactStore'),
columns: [
....
],
features: [{
ftype: 'grouping',
groupHeaderTpl: ['{columnName}: {name} - ({rows.length} employees)'],
hideGroupedHeader: true,
startCollapsed: false
}],
viewConfig: { id: 'contactlistgridview' }
},
{
xtype: 'gridpanel',
id: 'caselistgrid',
store: Ext.data.StoreManager.lookup('caseStore'),
columns: [
{ text: 'Title', dataIndex: 'title' },
{ text: 'Description', dataIndex: 'description' },
{ text: 'Ticket number', dataIndex: 'ticketnumber' }
],
viewConfig: { id: 'caselistgridview' }
}
]




this.callParent(arguments);
}
});


Anything obvious I'm doing wrong ? I've attached a screenshot of the layout. I just want to add a listener on the panel that's holding the menu to the left ("Login").

But it's also triggering when I click all over the panel in the middle with the X on. Also, when I debug, the value of e.ID is always the one of the "Login" item, even when I click right in the middle.

drunkmoose
6 Jun 2014, 1:34 PM
I found this did the trick

http://www.fusioncube.net/index.php/sencha-extjs-4-make-any-component-fire-a-click-event/comment-page-1

This way I can listen to 'click' event for 'panel' in my controller.