1
我有兩個商店:localstorage和服務器上的json,我試圖從json下載數據到本地。請看看有什麼錯:Sencha Touch Sync商店
/store/Notes.js
Ext.define("NotesApp.store.Notes", {
extend: "Ext.data.Store",
requires: "Ext.data.proxy.LocalStorage",
config: {
storeId: 'Notes',
model: "NotesApp.model.Note",
proxy: {
type: 'localstorage',
id: 'notes-app-store'
},
sorters: [{
property: 'dateCreated',
direction: 'DESC'
}],
grouper: {
sortProperty: "dateCreated",
direction: "DESC",
groupFn: function (record) {
if (record && record.data.dateCreated) {
return record.data.dateCreated.toDateString();
} else {
return '';
}
}
}
}
});
/store/Online.js
Ext.define( 「NotesApp.store.Online」 「Ext.data.Store」, config:{
storeId: 'Online', proxy: { type: 'jsonp', url: 'http://server.com/made/qa.php', reader: { type: 'json' //rootProperty: 'results' } }, autoLoad: false, listeners: { load: function() { console.log("updating"); // Clear proxy from offline store Ext.getStore('Notes').proxy.clear(); console.log("updating1"); // Loop through records and fill the offline store this.each(function(record) { console.log("updating2"); Ext.getStore('Notes').add(record.data); }); // Sync the offline store Ext.getStore('Notes').sync(); console.log("updating3"); // Remove data from online store this.removeAll(); console.log("updated"); } }, fields: [ { name: 'id' }, { name: 'date_created' }, { name: 'question' }, { name: 'answer' }, { name: 'type' }, { name: 'author' } ] } });
當我需要更新我叫Ext.getStore('Online').load();
但控制檯沒有顯示「更新」後,其他任何東西。
我不知道哪裏出了問題?