0

我的导航有问题,我的页面如下所示:

Ext.define('MyApp.view.MeinView', {
    extend: 'Ext.navigation.View',

    config: {
        items: [
            {
                xtype: 'formpanel',
                title: 'MyApp',
                id: 'StartAnsicht',
                items: [
                    {
                        xtype: 'list',
                        docked: 'top',
                        height: 200,
                        ui: 'round',
                        itemTpl: [
                            '<div>{titel}: {inhalt}</div>'
                        ],
                        store: 'EintragStore'
                    },
                    {
                        xtype: 'button',
                        docked: 'bottom',
                        id: 'NeuerEintrag',
                        itemId: 'mybutton1',
                        ui: 'action',
                        text: 'New'
                    }
                ]
            }
        ],
        listeners: [
            {
                fn: 'onNeuerEintragTap',
                event: 'tap',
                delegate: '#NeuerEintrag'
            }
        ]
    },

    onNeuerEintragTap: function(button, e, eOpts) {
        this.push(Ext.create("MyApp.view.AddAnsicht", {
            title: "New Item"
        }));
    }

});

和:

Ext.define('MyApp.view.AddAnsicht', {
    extend: 'Ext.form.Panel',

    config: {
        id: 'AddAnsicht',
        items: [
            {
                xtype: 'button',
                docked: 'bottom',
                id: 'NeuSubmit',
                itemId: 'mybutton',
                ui: 'confirm',
                text: 'Add'
            }
        ],
        listeners: [
            {
                fn: 'onNeuSubmitTap',
                event: 'tap',
                delegate: '#NeuSubmit'
            }
        ]
    },

    onNeuSubmitTap: function(button, e, eOpts) {
        var inhalt = Ext.getStore('EintragStore');

        inhalt.add({ inhalt: '1', titel: '2' });
        inhalt.sync();

        this.push(Ext.create("MyApp.view.MeinView"));
    }

});

问题:当我到达第二面并单击按钮时,我得到:

Uncaught TypeError: Object [object Object] has no method 'push'

如何避免这种情况?

4

1 回答 1

1

错误来自this.push(Ext.create("MyApp.view.MeinView"));

你在做this.push inMyApp.view.AddAnsicht它是formPanel,但是formPanel 没有push 方法。

这就是Uncaught TypeError: Object [object Object] has no method 'push'错误的原因。

您正试图推MyApp.view.MeinView (navigation View)MyApp.view.AddAnsicht (form Panel),但这是错误的..

您不能将导航视图推送到 formPanel,但可以将 formpanel 推送到导航视图。

你真正想做的是什么?

于 2013-07-27T09:45:59.520 回答