I look for the best method to define the menu actions in ExtJS 4.2.
I used to define the menu action with the handler
configuration :
items: [{
text: 'About...',
icon: Paths.img + 'information.png',
handler: function(){MyApp.app.getController('Gui').onMenuAbout()}
},{
I was adviced that this method is not good.
I now found this method : I'm using itemId
s and the control
-method in controllers.
My view:
Ext.define('Mb.view.gui.HelpMenu', {
extend: 'Ext.button.Button',
icon: Paths.img + 'help.png',
menu: {
items: [{
text: 'About...',
icon: Paths.img + 'information.png',
itemId: 'menuAbout'
},{
...
My controller:
Ext.define('Mb.controller.Gui', {
extend: 'Ext.app.Controller',
init: function(){
this.control({
'#menuAbout': {
click: this.onMenuAbout
}
})
},
onMenuAbout: function(){...},
...
Is this the recommended way to go or is there a better solution ?