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' });
}
感謝
斯納