我正在建造一个使用Sencha Touch的Wordpress网站。我创建了一个将帖子转换为JSON以供应用程序读取的插件。从JSON商店Sencha Touch Carousel
在应用程序“邮政视图”我加载发布信息(标题,正文等),我想有一个旋转木马,显示阵列中的所有图像“图像”,我已通过json内该职位。
我的应用程序使用MVC结构(因为我喜欢我的牙齿被拉动的感觉),所以我需要一个帖子列表将数据传递到Single Posts面板,然后将Images数组放入轮播。
我们的目标是从列表中选择一个帖子,将数据加载到postsingleview(目前的工作),然后从该职位进入转盘加载图像。
任何和所有的建议非常赞赏。
这是我到目前为止有:
JSON:http://pastie.org/2497239(堆栈的codewrapper不会让我显示JSON,这里的引擎收录)
PostListView:
App.views.PostListView = Ext.extend(Ext.Panel, {
postStore: Ext.emptyFn,
postList: Ext.emptyFn,
id:'postlistview',
layout: 'card',
initComponent: function() {
this.postList = new Ext.List({
store: App.stores.postStore,
grouped: true,
emptyText: '<div style="margin:5px;">No notes cached.</div>',
onItemDisclosure: true,
indexBar: true,
itemTpl: '<div class="list-item-title">{title}</div>',
});
this.postList.on('disclose', function (record) {
this.onViewPost(record);
}, this),
this.items = [this.postList];
App.views.PostListView.superclass.initComponent.call(this);
},
onViewPost: function (record) {
Ext.dispatch({
controller: App.controllers.masterController,
action: 'viewpost',
record: record,
});
},
});
主控制器,带有“ ViewPost“动作:
'viewpost': function (options) {
App.views.postSingleView.bodycard.update(options.record.data);
App.views.postSingleView.funfactcard.update(options.record.data);
App.views.postSingleView.crosscard.update(options.record.data);
App.views.postSingleView.historycard.update(options.record.data);
App.views.postSingleView.architectcard.update(options.record.data);
App.views.postSingleView.commentcard.update(options.record.data);
App.views.postSingleView.dealscard.update(options.record.data);
App.views.postView.setActiveItem(
App.views.postSingleView,
{ type: 'slide', direction: 'left' }
);
},
发布单个Vi ew(显示帖子中的数据)
App.views.PostSingleView = Ext.extend(Ext.Panel, {
title:'Single Post',
id:'postsingleview',
layout:{
type:'vbox',
align:'stretch',
pack:'end'
},
defaults: { flex: 1 },
initComponent: function() {
this.bodycard = new Ext.Component({
title:'Info',
scroll:'vertical',
cls : 'card bottomcard card3',
iconCls:'info',
tpl: '<tpl for=".">' +
'<div id="bottomcard-container">{body}</div>' +
'</tpl>',
});
[... There are 7 Ext.Components, but I want to keep it short so I'm deleting them for Display on Stack ]
this.postSinglePanel = new Ext.TabPanel({
dock:'bottom',
id:'singlepost-bottompanel',
items:[
this.bodycard,
this.funfactcard,
this.crosscard,
this.historycard,
this.architectcard,
this.commentcard,
this.dealscard,
],
tabBar:{
dock:'bottom',
scroll:'horizontal',
layout:{
pack:'center',
},
},
});
var numberOfPages = 4;
// Create pages for the carousel
var pages = [];
for (var i=0; i<numberOfPages; i++) {
pages.push(new Ext.Component({
id: 'page'+i,
cls: 'page',
tpl: '<tpl for=".">{body}</tpl>',
}));
}
// Create the carousel
this.carousel = new Ext.Carousel({
id: 'carousel',
defaults: {
cls: 'card'
},
items: pages,
});
this.items = [this.carousel, this.postSinglePanel];
App.views.PostSingleView.superclass.initComponent.call(this);
},
});
它可以帮助,但我需要如何从我的Posts.store获取信息,并将其反馈到我的旋转木马。我已经有了一个生成它们的动态方法。我遇到的唯一问题是更新卡片中的数据。 – Tom
你需要动态更新数据吗?或者只是在创建传送带时? – Rubinsh
好吧,我有一个用户将选择的博客帖子列表,它将他们带到“发布”页面,主要向他们展示帖子的主体。这是一个选项卡视图,带有“图像”选项卡,可以传送到旋转木马。当用户选择列表中的帖子时,我需要生成轮播。 – Tom