导航无法正常工作

时间:2013-07-27 09:11:06

标签: extjs sencha-touch sencha-touch-2

我的导航有问题,我的页面看起来像这样:

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'

如何避免这种情况?

1 个答案:

答案 0 :(得分:1)

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

你在MyApp.view.AddAnsicht执行this.push,它是formPanel,但是formPanel没有push方法。

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

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

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

你真的想做什么?