我不确定这里有多少人使用过 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!');}
}
}
});
任何帮助将不胜感激。 谢谢。
最佳答案
使用卡片切换事件:
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'
}]
});
}
});
关于javascript - 在 Sencha Touch 中更改轮播页面时触发运行函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4270251/