2011-11-30 46 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

相关问题