2

我不确定这里有多少人使用过 Sencha Touch js 库,但我有一个问题必须很简单,尽管我尝试了很多次但都失败了。基本上,我有一个轮播,当你滑动时会翻阅结果,我想在每次显示新页面时触发一个函数。
任何人都知道如何做到这一点?我尝试向它添加一个侦听器,但由于某种原因这不起作用。像这样的东西:

var apCarousel = new Ext.Carousel({
            direction: 'horizontal',
            activeItem: 0,
            ui: 'dark',
            itemId  :   "apCarousel",
            items: pageItems,
            listeners   :   {
                click   :   {
                    element :   this,
                    fn  :   function(){alert('yo!');}
                }
            }
        });

任何帮助将不胜感激。谢谢。

4

2 回答 2

4

使用 cardswitch 事件:

Ext.setup({
    onReady: function(){
        new Ext.Carousel({
            fullscreen: true,
            listeners: {
                cardswitch: function(container, newCard, oldCard, index){
                    console.log(container, newCard, oldCard, index);
                }
            },
            items: [{
                html: 'a'
            },{
                html: 'b'
            },{
                html: 'c'
            }]
        });
    }
});
于 2010-11-29T13:46:27.140 回答
0

我有同样的问题,尝试添加监听器,如:

listeners: {
             cardswitch:
             {
                fn: function()
                {
                  alert(this.getActiveIndex() );
                }
              },
             }
于 2010-11-29T13:03:47.850 回答