PDA

View Full Version : Beginner problem with Event of Menu item



mannyk
9 Sep 2010, 10:20 PM
Hello,
I would like to fire an event when a menu button is pressed.
However, this does not seem to work. Here is my code:


xtype: 'button',
text: 'Import/Export',
icon: '../../Images/Icons/table_refresh.png',
menu: {
xtype: 'menu',
id: 'ImportExportMenu',
items: [
{
xtype: 'menuitem',
text: 'Import',
icon: '../../Images/Icons/table_add.png',
ref: '../../../../onAddressImport',
id: 'MenuImportItem'
},
{
xtype: 'menuitem',
text: 'Export',
icon: '../../Images/Icons/table_go.png',
ref: '../../../../onAddressExport',
id: 'MenuExportItem'
}
]
}
And the event code in the class


myPanel = Ext.extend(MyPanelUI, {
initComponent: function () {
myPanel.superclass.initComponent.call(this);
this.onAddressImport.on('click', this.onAddressImportClick, this);

j-joey
10 Sep 2010, 1:50 PM
try debugging with firebug. maybe a javascript error prevents it.

bingyupiaoyao
15 Nov 2010, 5:35 AM
I also have this problem, Anyone can help?

bingyupiaoyao
15 Nov 2010, 5:50 AM
MyToolbarUi.js


MyToolbarUi = Ext.extend(Ext.Toolbar, {
width: 400,
initComponent: function() {
this.items = [
{
xtype: 'button',
text: 'MyApp',
ref: 'myAppItm',
menu: {
xtype: 'menu',
items: [
{
xtype: 'menuitem',
text: 'About',
ref: '../../tttt'
},
{
xtype: 'menuitem',
text: 'Preferences',
ref: '../../prefItm'
}
]
}
},
{
xtype: 'button',
text: 'Tools',
menu: {
xtype: 'menu',
items: [
{
xtype: 'menuitem',
text: 'Import',
ref: '../../importItm'
},
{
xtype: 'menuitem',
text: 'Export',
ref: '../../exportItm'
}
]
}
}
];
MyToolbarUi.superclass.initComponent.call(this);
}
});

MyToolbar = Ext.extend(MyToolbarUi, {
initComponent: function() {
MyToolbar.superclass.initComponent.call(this);

alert(this.tttt);
}
});

It give "undefined"...

bozzoz
16 Nov 2010, 11:30 PM
There is a problem with autoRef for menu inside a button for Ext!

Look here!
http://www.sencha.com/forum/showthread.php?99895-MenuItem-autoRef&p=470296#post470296

Bye