2014-02-11 10 views
5
var myLocalStore = Ext.getStore('Default'); 
myLocalStore.load(); 
var now = new Date(); 
var cardId = (now.getTime()).toString() + (this.getRandomInt(0, 100)).toString(); 
var entry1 = { id: cardId, dateCreated: now, title: 'The Title', narrative: 'the Text' }; 
myLocalStore.add(entry1); 
myLocalStore.sync(); 
console.log(entry1); 

Die Konsole Ausgänge:Kann mir jemand sagen, warum dieser Code nicht einen Eintrag in localstorage erstellt?

Object{id: "136575772251069", dateCreated: Fri Apr 12 2013 17:08:42 GMT+0800 (Taipei Standard Time), title: "The Title", narrative: "the Text"} 

Antwort

7

Update: Erfolg!

Ich habe meinen Code so aktualisiert, dass er so aussieht.

var myLocalStore = Ext.getStore('Default'); 
var now = new Date(); 
var cardId = (now.getTime()).toString() + (this.getRandomInt(0, 100)).toString(); 
var entry = Ext.create('PinYin.model.Default', {id: cardId, dateCreated: now, title: "test", narrative: "narrative"}); 
entry.save(); 
console.log(entry); 
Verwandte Themen