extjs - 菜单定义,遵循MVC原则的最佳实践是什么?

时间:2013-10-11 11:49:38

标签: extjs menu extjs-mvc extjs4.2

我寻找在ExtJS 4.2中定义菜单操作的最佳方法。

我曾经使用handler配置来定义菜单操作:

items: [{
    text: 'About...',
    icon: Paths.img + 'information.png',
    handler: function(){MyApp.app.getController('Gui').onMenuAbout()}
},{

I was adviced这种方法不好。

我现在发现了这个方法:我在控制器中使用itemIdcontrol - 方法。

我的观点:

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(){...},
    ...

这是推荐的方式还是有更好的解决方案?

0 个答案:

没有答案