2011-11-30 45 views
0

我按照教程:http://miamicoder.com/2011/writing-a-sencha-touch-application-part-3/如何在sencha touch中將筆記保存在本地存儲中?

添加和保存筆記。但保存筆記不適合我。有什麼問題?

我的代碼來保存:

NotesApp.views.noteEditorTopToolbar = new Ext.Toolbar({ 
      title: 'Edit Note', 
      items: [ 

       { xtype: 'spacer' }, 
       { 
        text: 'Save', 
        ui: 'action', 
        handler: function() { 
         // TODO: Save current note. 

         var noteEditor = NotesApp.views.noteEditor; 

        var currentNote = noteEditor.getRecord(); 

       // Update the note with the values in the form fields. 
       noteEditor.updateRecord(currentNote); 

       //var errors = currentNote.validate(); 
       /*if (!errors.isValid()) { 
       currentNote.reject(); 
       Ext.Msg.alert('Wait!', errors.getByField('title')[0].message, Ext.emptyFn); 
       return; 
      }*/ 

       var notesList = NotesApp.views.notesList; 


       var notesStore = notesList.getStore(); 






       if (notesStore.findRecord('id', currentNote.data.id) === null) { 
       alert('fjghjkh'); 
       notesStore.add(currentNote); 
      } else { 
       alert('fjghjkh'); 
       currentNote.setDirty(); 
      } 

      notesStore.sync(); 

notesStore.sort([{屬性: '日期',方向: 'DESC'}]);

  notesList.refresh(); 

      NotesApp.views.viewport.setActiveItem('notesListContainer', { type: 'slide', direction: 'right' }); 

      } 

感謝
斯納

回答

1

我有同樣的問題。就我而言,解決方案是將config'autoLoad:true'添加到我定義的商店。 也許這個答案有助於其他人,他們通過搜索類似的問題來發現這個問題。 Regards, Andreas

相關問題