javascript - 导航 View Sencha Touch 2

标签 javascript sencha-touch-2

我在 Sencha Touch 2 中的 NavigationView 有问题。 当我按下“后退”按钮时,我无法浏览多个窗口。

我使用 view.push() 和 view.pop() 进行导航。

view.js:

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

config: {
    id: 'nvView',
    items: [
        {
            xtype: 'toolbar',
            docked: 'bottom',
            layout: {
                align: 'center',
                pack: 'center',
                type: 'hbox'
            },
            items: [
                {
                    xtype: 'button',
                    iconAlign: 'center',
                    iconCls: 'info',
                    iconMask: true,
                    text: 'Ayuda'
                },
                {
                    xtype: 'button',
                    iconAlign: 'center',
                    iconCls: 'compose',
                    iconMask: true,
                    text: 'Guardar'
                },
                {
                    xtype: 'button',
                    id: 'volver',
                    iconAlign: 'center',
                    iconCls: 'reply',
                    iconMask: true,
                    text: 'Volver'
                }
            ]
        },
        {
            xtype: 'formpanel',
            title: 'View',
            html: 'View1',
            id: 'View1',
            styleHtmlContent: true,
            items: [
                {
                    xtype: 'button',
                    docked: 'bottom',
                    id: 'bView1',
                    margin: 10,
                    ui: 'forward',
                    text: 'siguiente'
                }
            ]
        }
    ]
}
});

view2.js:

Ext.define('MyApp.view.View2', {
extend: 'Ext.form.Panel',
alias: 'widget.View2',

config: {
    fullscreen: true,
    html: 'View2',
    id: 'View2',
    styleHtmlContent: true,
    items: [
        {
            xtype: 'button',
            docked: 'bottom',
            id: 'bView2',
            margin: 10,
            ui: 'forward',
            text: 'siguiente'
        }
    ]
}
});

view3.js:

Ext.define('MyApp.view.View3', {
extend: 'Ext.form.Panel',
alias: 'widget.View3',

config: {
    fullscreen: true,
    html: 'View3',
    id: 'View3',
    styleHtmlContent: true,
    items: [
        {
            xtype: 'button',
            docked: 'bottom',
            id: 'bView3',
            margin: 10,
            ui: 'forward',
            text: 'siguiente'
        }
    ]
}
});

ViewController.js:

Ext.define('MyApp.controller.ViewController', {
extend: 'Ext.app.Controller',

config: {
    views: [
        'View'
    ],

    refs: {
        bView1: 'bView1',
        bView2: 'bView2'
    },

    control: {
        "#bView1": {
            tap: 'onView1'
        },
        "#bView2": {
            tap: 'onView2'
        }
    }
},

onView1: function(button, e, options) {
    button.up('navigationview').push({
        xtype: 'View2',
        title: 'View2'
    });
},

onView2: function(button, e, options) {
    button.up('navigationview').push({
        xtype: 'View3',
        title: 'View3'
    });
}
});

我的问题的一个例子是: 我从 view1 开始,然后按下“siguiente”按钮,然后转到 view2。如果我按下“后退”按钮(在导航 View 中),我会进入 view1,然后我按下“siguiente”按钮并进入 view2,但在 view2 中,我按下“siguiente”按钮我无法进入 view3。

非常感谢您!

最佳答案

因为你使用了id,所以当你第二次启动它时会发生冲突,显示警告并且功能无法正常工作。如果您使用 itemId,您将是安全的。

itemId: 'bView1' //same for other view bView2, bView3

要在 Controller 中引用您的 itemId,例如:

refs: {
    bView1: '[itemId=bView1]',
    bhView2: '[itemId=bView2]',
    bhView3: '[itemId=bView3]'
},

control: {
     bView1: {
         tap: 'onView1'
     },
     bhView2: {
         tap: 'onView2'
     },
},

onView1: function(button, e, options) {
    button.up('navigationview').push({
        xtype: 'View2',
        title: 'View2'
    });
},

onView2: function(button, e, options) {
    button.up('navigationview').push({
        xtype: 'View3',
        title: 'View3'
    });
}

希望对您有所帮助:)

关于javascript - 导航 View Sencha Touch 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14318814/

相关文章:

javascript - 如何为以下 Angular 函数编写单元测试用例

json - Sencha touch 2 加载存储和带有嵌套 JSON 的关联存储

android - 一个本地容器(.apk),可以将 html 文件作为应用程序加载到设备中

javascript - sencha touch 动态构建表单面板

javascript - 这是什么 hr = hr>=12 ? hr-12 : hr; means?

javascript - 如何更改 Google 组织结构图链接线颜色和粗细?

javascript - VisualStudio javascript 混淆器窗口

javascript - 必须为内部事件指定默认脚本语言

android - Ext.device.notification.show 在 Phonegap 中创建错误 - Sencha Touch 2

javascript - 如何通过javascript将文件从浏览器保存到本地目录?