Javascript 对多个视图使用基本导航视图仅引用第一个视图

Javascript 对多个视图使用基本导航视图仅引用第一个视图,javascript,sencha-touch-2,Javascript,Sencha Touch 2,我正在开发sencha touch移动应用程序,我遇到了一个问题。我将尽可能多地介绍细节 我有一个选项卡面板,包含两项:主视图和联系人视图 Ext.define('myapp.view.Main', { extend: 'Ext.TabPanel', requires: [ 'myapp.view.Home', 'myapp.view.Contacts' ], config: { fullscreen : true

我正在开发sencha touch移动应用程序,我遇到了一个问题。我将尽可能多地介绍细节

我有一个选项卡面板,包含两项:主视图和联系人视图

Ext.define('myapp.view.Main', {
    extend: 'Ext.TabPanel',
    requires: [
        'myapp.view.Home',
        'myapp.view.Contacts'
    ],

    config: {
        fullscreen : true,
        tabBar: {
            docked: 'bottom',
           defaults: {
                flex: 1
        },
        layout: {
            pack: 'center'
            }

        },
        layout: {
            type: 'card',
            animation: {
                type: 'slide'
            }
        },
       items: [

            { xtype: 'homeView' },
            { xtype: 'contactsView' }

    ]
}
}))

我希望每个项目都有相同的导航视图。导航视图有一个按钮,可按下另一个视图

为此,我创建了一个BaseNavigationView.js

Ext.define('myapp.view.BaseNavigationView', {
    extend : 'Ext.navigation.View',
    xtype : 'baseNavigationView',

    config : {
        navigationBar : {
            items : [ {
                xtype : 'button',
                text : 'My Info',
                align : 'right',
                id : 'myInfoButton',
                ui : 'small'
            }

            ]
        },
    }
});
在我使用的两个视图(主页和联系人)中

以获得两者的导航视图

到目前为止,一切都很顺利

现在对于控制器,我想在
MyInfo
按钮上添加一个点击事件,并在相应视图中点击时按下
myInfoView

在我添加到控制部分的控制器中:

'#myInfoButton' : {
    tap : 'onMyInfoButton'
}
和处理程序:

onMyInfoButton: function(self, e, eOpts) {
    //Create a new instance of the 
    if (!this.myInfoView) {
        this.myInfoView= Ext.create('myApp.view.myInfoView');
    }
    //Get the parent navigation view and push the view
    self.up('baseNavigationView').push(this.myInfoView);
}
当我运行应用程序时,Home和Contact视图都正确地显示了带有“myInfoButton”的导航视图

问题

当我在“主页”视图中单击myInfoView按钮时,“myInfoView”被正确地按入后退按钮

但是,如果我切换到“联系人”选项卡并单击myInfoButton,则会在“主页”选项卡而不是“联系人”选项卡中按下“myInfoView”。因此,在contacts选项卡中,什么都没有发生,我必须返回Home选项卡以查看推送的视图

这就像是
self.up('baseNavigationView')
总是引用主页的导航视图,而不是联系人,即使单击联系人视图中的按钮也是如此

我如何解决这个问题

非常感谢你的帮助

onMyInfoButton: function(self, e, eOpts) {
    //Create a new instance of the 
    if (!this.myInfoView) {
        this.myInfoView= Ext.create('myApp.view.myInfoView');
    }
    //Get the parent navigation view and push the view
    self.up('baseNavigationView').push(this.myInfoView);
}