0
我一直按照Sencha指導,但我似乎沒有得到我的服務器的響應。我沒有在控制檯中發現任何錯誤,所以我有點難住。任何幫助將是驚人的。數據沒有通過JSONP Sencha Touch 2加載到列表
這在我看來是
store: {
fields: ['title', 'description', 'time', 'date', 'image', 'longdesc'],
proxy: {
type: 'jsonp',
url: 'http://mydomain.co.uk/scheduledata.json',
reader: {
type: 'json',
rootProperty: 'scheduleData'
}
}
},
itemTpl: '<div class="white-circle">{time}</div> <div class="list-title">{title}</div> <div class="list-desc">{description}</div><div class="arrow-right"></div>'
和託管在我的服務器上的JSON文件的存儲配置。
{
"scheduleData" : [
{
"title" : "Event One",
"description" : "Meet and Greet",
"time" : "10:45",
"date" : "Friday",
"image" : "./resources/imageone.jpg",
"longdesc" : "This is a longer description"
},
{
"title" : "Event Two",
"description" : "Q and A",
"time" : "11:00",
"date" : "Friday",
"image" : "./resources/imagetwo.jpg",
"longdesc" : "This is a longer description still"
}
]
}
更新:這裏是完整的JS文件與配置:
Ext.define('scheduleApp.view.Home', {
//extend: 'Ext.Panel',
//xtype: 'homepanel',
extend: 'Ext.navigation.View',
xtype: 'schedulepanel',
id: 'sched',
config: {
navigationBar: {
hidden: true
},
title: '<span class="logo"></span>',
items: [
{
xtype: 'container',
layout: 'vbox',
items: [
{
xtype: 'container',
flex: 2,
items: [
{
xtype: 'container',
layout: {
type: 'hbox'
},
items: [
{
html: '<img src="./resources/map.jpg" width="100%" height="100%"/>'
}
]
}
]
},
{
xtype: 'container',
flex: 5,
layout: {
type: 'fit'
},
items: [
{
xtype: 'list',
store: {
type: 'tree',
sorters: 'date',
fields: ['title', 'description', 'time', 'date', 'image', 'longdesc'],
proxy: {
type: 'jsonp',
url: 'http://www.mydomain.co.uk/scheduledata.json',
reader: {
type: 'json',
rootProperty: 'scheduleData'
}
}
},
itemTpl: '<div class="white-circle">{time}</div> <div class="list-title">{title}</div> <div class="list-desc">{description}</div><div class="arrow-right"></div>'
}
]
}
]
}
]
}
});
使用Chrome/Firefox dev控制檯檢查網絡頁面。你應該在那裏看到你的JSON文件的請求。 – sha
你可以發佈完整的'list'代碼嗎? – SachinGutte
@SachinG對不起Sachin我很困惑。這是所有的列表代碼,而不是xtype – MrFirthy