【发布时间】:2011-05-02 16:48:28
【问题描述】:
我是 sencha touch 的新手,看过所有的视频播客,但仍然不明白如何从标签栏“显示”面板(顶部的栏!)以及如何在没有任何幻灯片或其他东西的情况下从一个面板切换到另一个面板(请显示出来!)
还有更多的事情要做,比如拥有一个预加载器并从 JSON 中获取数据,然后显示嵌套列表。但是现在我被困在这个简单的场景中......
这是我目前所拥有的......
这是 index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test Sencha 3</title>
<script type="text/javascript" src="lib/touch/sencha-touch.js"></script>
<link href="lib/touch/resources/css/sencha-touch.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="phonegap.js"></script>
<script src="app/app.js" type="text/javascript"></script>
<script src="app/views/startcard.js" type="text/javascript"></script>
<script src="app/views/secondcard.js" type="text/javascript"></script>
<script src="app/views/plain.js" type="text/javascript"></script>
<script src="app/views/Viewport.js" type="text/javascript"></script>
</head><body></body>
app.js
Testdemo = new Ext.Application({
name: "TestDemo",
launch: function() {
this.views.viewport = new this.views.Viewport();
this.views.homecard = this.views.viewport.getComponent('startcard');
}
});
Viewport.js
TestDemo.views.Viewport = Ext.extend(Ext.TabPanel, {
fullscreen: true,
initComponent: function() {
Ext.apply(this, {
tabBar: {
dock: 'bottom',
layout: {
pack: 'center'
}
},
items: [
{ xtype: 'startcard'},
{ xtype: 'secondcard'},
]
});
TestDemo.views.Viewport.superclass.initComponent.apply(this, arguments);
}
});
startcard.js
myPrefs = function() {
//here is the problem! How can I display the panel myPrefs??
this.StartCard.setActiveItem('myPrefs', {type:'slide', direction:'down'});
}
refreshHome = function() {
alert("Refresh me!");
}
var somelist = new Ext.Component({
title: 'testline 1',
cls: 'info',
html: 'This is plain Text.<br />Some JSON-Data should be listed here...'
})
TestDemo.views.StartCard = Ext.extend(Ext.Panel, {
title: "TestDemo",
iconCls: "home",
styleHtmlContent: true,
scroll: 'vertical',
initComponent: function() {
Ext.apply(this, {
dockedItems: [
{
xtype: 'toolbar',
dock: 'top',
title: 'Some Test App',
items: [
{
iconMask: true,
ui: 'plain',
iconCls: 'settings',
itemId: 'btnHomeMore',
title: 'Do I need a title???',
handler: myPrefs
},
{
xtype: 'spacer'
},
{
iconMask: true,
ui: 'plain',
iconCls: 'refresh',
itemId: 'btnRefreshMe',
title: 'Refresh, i guess',
handler: refreshHome
}
]
}
],
items: [
{
itemId: 'MyStartPage',
html: 'This is just a test'
}
]
});
TestDemo.views.StartCard.superclass.initComponent.apply(this, arguments);
}
});
Ext.reg('startcard', TestDemo.views.StartCard);
【问题讨论】:
标签: sencha-touch viewport