我的整个 Sencha Touch 应用程序(对于 app.js)有以下代码。我正在尝试获取它,以便将 JSON 文件加载到本地存储中,并且用户名字段显示在“数据”页面上的列表中。
任何提示出了什么问题?应用程序本身加载正常,但 JSON 没有加载到本地存储或显示任何内容。
var helloWorld = new Ext.Application({
Users: Ext.regModel('Users', {
fields:[
{name:'id'},
{name:'username'},
{name:'password'},
]
}),
onlineStore: new Ext.data.Store({
model: 'Users',
proxy: {
type: 'scripttag',
url: 'http://selectout.net/manage/oil/www/samplecustomers.json',
reader: new Ext.data.JsonReader({
root: 'users'
}),
timeout: 2000,
listeners: {
exception:function () {
console.log("I think we are offline");
helloWorld.Users.bindStore(helloWorld.offlineStore);
helloWorld.offlineStore.load();
}
}
}
}),
offlineStore: new Ext.data.Store({
model: 'Users',
proxy: {
type: 'localstorage',
id: 'helloworld'
}
}),
launch: function() {
this.tabs = new Ext.TabPanel({
fullscreen: true,
dockedItems: [{xtype:'toolbar', title:'Hello World'}],
tabBar: {
ui: 'dark',
layout: {
pack: 'center'
}
},
items: [
{cls:'hello', title:'Hello'},
{cls:'world', title:'World'},
{
cls: 'Users',
title: 'Users',
xtype: 'list',
store: null,
itemTpl:'{username}'
}
]
});
this.Users = this.tabs.items.getAt(2);
this.onlineStore.addListener('load', function () {
console.log("I think we are online");
helloWorld.offlineStore.proxy.clear();
helloWorld.offlineStore.sync();
helloWorld.Users.bindStore(helloWorld.offlineStore);
});
this.onlineStore.load();
}
});