ExtJS 4.2 でメニュー アクションを定義する最良の方法を探しています。
私は設定でメニューアクションを定義していましたhandler
:
items: [{
text: 'About...',
icon: Paths.img + 'information.png',
handler: function(){MyApp.app.getController('Gui').onMenuAbout()}
},{
この方法は良くないと忠告されました。
私は今、この方法を見つけました:私はコントローラでitemId
s とcontrol
-method を使用しています。
私の見解:
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'
},{
...
私のコントローラー:
Ext.define('Mb.controller.Gui', {
extend: 'Ext.app.Controller',
init: function(){
this.control({
'#menuAbout': {
click: this.onMenuAbout
}
})
},
onMenuAbout: function(){...},
...
これは推奨される方法ですか、それともより良い解決策がありますか?