简体   繁体   中英

Sencha Touch 2 - Carousel Stuck on First Panel Only After Build

I have a carousel in a panel which displays and works fine before I build the app through the sencha sdk. After I've built it, however, the carousel still displays properly but no longer allows me to swipe between the items.

Ext.define('SycsApp.view.HotOffers', {
    extend: 'Ext.Panel',
    requires: ['Ext.carousel.Carousel', 'Ext.TitleBar'],

    config: {
            layout: 'card',
            items: [
                {
                    docked: 'top',
                    xtype: 'titlebar',
                    ui: 'top-sub',
                    title: 'Hot Offers',
                },
                {
                    id: 'hotOffersCarousel',
                    xtype: 'carousel',
                    width: '100%',
                    items: [
                        {
                            html : 'Item 1',
                            style: 'background-color: #5E99CC'
                        },
                        {
                            html : 'Item 2',
                            style: 'background-color: #759E60'
                        },
                        {
                            html : 'Item 3'
                        }
                    ]
                }
            ]
    }
});

The reason the layout is set to card is that this view is part of an encompassing tab panel. I'm not getting any error messages from the console when I run the app after the build, either.

Any help with why this would possibly be happening would be greatly appreciated.

The issue was caused by the way it was being added to the main card view.

Ext.define('SycsApp.view.Main', {
extend: 'Ext.tab.Panel',
xtype: 'mainView',
requires:  ['SycsApp.view.HotOffers'],

config: {
    tabBarPosition: 'bottom',
    id: 'MainView',
    ui: 'bottom',
    layout: 'card',
    items: [
        {
            title: 'Hot Offers',
            layout: 'fit',
            iconCls: 'hotoffer',
            //items: [Ext.create('SycsApp.view.HotOffers')], // carousel doesn't work after build
            items:  [{xtype: 'hotOffersView'}] // carousel works after build
        },
        {
            title: 'All Savings',
            layout: 'fit',
            iconCls: 'list',
            items:  [{xtype: 'allSavingsMainView'}]
        }
    ]
}

});

The xtype: 'hotOffersView' must be added to the Hot Offers view:

Ext.define('SycsApp.view.HotOffers', {
    extend: 'Ext.Panel',
    xtype: 'hotOffersView',
    requires: ['Ext.carousel.Carousel', 'Ext.TitleBar'],

    config: {
            layout: 'card',
            items: [
                {
                    docked: 'top',
                    xtype: 'titlebar',
                    ui: 'top-sub',
                    title: 'Hot Offers',
                },
                {
                    id: 'hotOffersCarousel',
                    xtype: 'carousel',
                    width: '100%',
                    items: [
                        {
                            html : 'Item 1',
                            style: 'background-color: #5E99CC'
                        },
                        {
                            html : 'Item 2',
                            style: 'background-color: #759E60'
                        },
                        {
                            html : 'Item 3'
                        }
                    ]
                }
            ]
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM