【发布时间】:2014-02-21 23:32:49
【问题描述】:
谁能指出我在以下代码中做错了什么?我要做的就是使用容器创建卡片布局并使用两个简单的按钮处理程序函数导航它们。
P.S:我正在使用 Sencha Architect 3 来执行此操作。因此只有处理函数代码对我来说是可编辑的。
Ext.define('Chatper04.view.cardContainer', {
extend: 'Ext.Container',
alias: 'widget.cardContainer',
requires: [
'Ext.Toolbar',
'Ext.Button',
'Ext.Spacer'
],
config: {
fullscreen: true,
itemId: 'cardContainer',
scrollable: 'horizontal',
layout: {
type: 'card',
animation: 'slide'
},
items: [
{
xtype: 'toolbar',
docked: 'top',
title: 'Card Layout',
items: [
{
xtype: 'button',
handler: function(button, e) {
var currentContainer = cardContainer.getActiveItem(),
innerItems = cardContainer.getInnerItems(),
totalItems = innerItems.length,
currentIndex = innerItems.indexOf(currentContainer),
direction,
newIndex;
newIndex = currentIndex > 0 ? (currentIndex - 1) : (totalItems - 1);
cardContainer.animateActiveItem(newIndex, { type : 'slide',direction : 'right' });
},
ui: 'back',
text: 'Back'
},
{
xtype: 'spacer'
},
{
xtype: 'button',
handler: function(button, e) {
var currentContainer = cardContainer.getActiveItem(),
innerItems = cardContainer.getInnerItems(),
totalItems = innerItems.length,
currentIndex = innerItems.indexOf(currentContainer),
direction,
newIndex;
newIndex = currentIndex < (totalItems - 1) ? (currentIndex + 1) : 0;
cardContainer.animateActiveItem(newIndex, { type : 'slide',direction : 'left' });
},
ui: 'forward',
text: 'Forward'
}
]
},
{
xtype: 'component',
html: 'Card 1',
style: 'background-color: #99F;'
},
{
xtype: 'component',
html: 'Card 2',
style: 'background-color: #F99;'
},
{
xtype: 'component',
html: 'Card 3',
style: 'background-color: #9F9;'
}
]
}
});
我已经为此苦苦挣扎了好几个小时。因此,我们非常感谢您对此提供任何帮助。
【问题讨论】:
-
你得到的错误是什么?
标签: extjs sencha-touch extjs4.1 sencha-architect