在移动网络应用中加载多个标签和/或其观点时遇到问题

时间:2013-03-12 12:58:50

标签: javascript sencha-touch sencha-touch-2

我正在使用sencha touch制作移动应用。当用户登录然后他/她看到家庭视图时,这个应用程序做了什么。在这个home view上有两个按钮。这两个按钮将用户带到各自的视图,即AppointmentsMessages。这两个视图底部有三个标签按钮,即Home, Appointments, Messages。主页按钮将用户带回到home view,其中包含两个按钮。而AppointmentsMessages按钮会将他带到自己的视野中。

这是我的home view

enter image description here

如您所见,此视图中没有标签。以下是此视图的代码

config: {
    layout: {
        type: 'vbox'
    },
    items: [
        {
            xtype: 'titlebar',
            title: 'Home',
            docked: 'top'
        },
        {
            xtype: 'button',
            cls: 'messagesBtn',
            itemId: 'msg'
        },
        {
            xtype: 'button',
            cls: 'appointmentsBtn',
            itemId: 'appoint'
        }
    ],

    listeners: [
        {
            delegate: '#appoint',
            event: 'tap',
            fn: 'launchAppointmentView'
        }
    ]
},
launchAppointmentView: function () {
    this.fireEvent('launchAppointments');
}

用户点击后,可以说Button 2将他带到Appointments View。然后跟随视图向他显示

enter image description here

以及此视图的代码

config: {
    tabBarPosition: 'bottom',

    items: [
        {
            title: 'Appointments',
            iconCls: 'home',

            styleHtmlContent: true,
            scrollable: true,

            items: {
                docked: 'top',
                xtype: 'titlebar',
                title: 'Appointments'
            },

            html: ["Appointments View"].join("")
        }
    ]
}

加载此视图后,我只能看到约会的一个选项卡。我希望看到这三个视图的三个选项卡。 如何显示其他标签?

以下是我的消息视图

enter image description here

以下是代码

config: {
    tabBarPosition: 'bottom',

    items: [
        {
            title: 'Messages',
            iconCls: 'home',

            styleHtmlContent: true,
            scrollable: true,

            items: {
                docked: 'top',
                xtype: 'titlebar',
                title: 'Messages'
            },

            html: ["Messages View"].join("")
        }
    ]
}

我看不到这个视图,根本无法访问此视图,因为选项卡上没有消息按钮。 我怎样才能为这些视图添加所有标签按钮,当我点击它们时,它会让我看到它的视图?

1 个答案:

答案 0 :(得分:0)

以下是标签面板的示例:

Ext.create('Ext.TabPanel', {
    fullscreen: true,
    tabBarPosition: 'bottom',

    defaults: {
        styleHtmlContent: true
    },

    items: [
        {
            title: 'Home',
            iconCls: 'home',
            html: 'Home Screen'
        },
        {
            title: 'Contact',
            iconCls: 'user',
            html: 'Contact Screen'
        }
    ]
});

问题是,您尚未向项目列表中添加其他项目 - 它们必须包含标签,主页和联系人。您希望每个屏幕有3个标签,因此每个文件有3个项目。

对于事件,我喜欢创建一个控制器,为每个需要监听事件的项目提供参考,并为每个项目设置控制。如果您希望了解如何做到这一点,请告诉我。我将在下面添加一个简单示例来帮助您入门:

Ext.define('Analytics.controller.events.InstType', {
    extend: 'Ext.app.Controller',   

    config: { 
        refs: {
            instType: {
            selector: '#instType'
        }
    }
},

init: function() {
    // Start listening for toggle events on the 3 segmented button panels   
    this.control({   
        'instType': { 'toggle': function(container, button, pressed) {
                this.onGraphType(container, button, pressed);
            }
        }
    }); 
},

// note: these functions are called on both the buttons selected and the one that became unselected
// the 'pressed' param inidicates whether this is the selected button or not.
onGraphType: function (container, button, pressed) {
    if (pressed) { ..do stuff.. }
});
相关问题