Persistent Window?
I have a TableView menu for my application; one of the options is to write a note. Here is the invocation code:
winNote = Titanium.UI.createWindow({
url:'../application_windows/notes.js',
title:'Notes'
});
rowNote.addEventListener('click', function(e)
{
Titanium.UI.currentTab.open(winNote,{animated:true});
});
Pretty simple, straight forward, and works; but the notes window does not remain persistent. That is, if I click back on the top toolbar (iOS4 emulator), it goes back, and if I click the Notes row on the TableViewRow, it resets the content of the text area as if it is a new window.
Is there any special procedures I need to do in order to ensure the notes are persistent?
3 Answers
-
Accepted Answer
As far as I've seen Kitchen sink doesnt persist data after you've closed the page either.
I think what you want to do is store the data so you can get to it later. Try something like this:
//You'll have to pass in the clicked id some how.. perhaps store it as an //app property and access it like this: var winNoteProps = JSON.parse(Ti.App.Properties.getString("winNoteProps")); //get the data from a local database var db = Titanium.Database.open('mylocaldb'); var rows = db.execute('Select Notes from NotesTable where winNoteId = ' + winNoteProps.id); db.close(); var notes = rows.fieldByName('Notes'); taNotes.value = notes; //add an event listener to trigger the database save taNotes.addEventListener('blur', function(e){ var db = Titanium.Databse.open('mylocaldb'); db.execute('INSERT INTO NOTESTABLE (Notes, winNoteId) VALUES (?,?)', e.value, winNoteProps.id); db.close(); }
With this solution you'll have to setup the above database and tables before you use them. The best place is probably in the app.js file.
Check out this article for some more detailed look at database use and this guide for passing the variables between pages as application properties.
Hope this helps.
-
can you post the code from notes.js?
I am going to guess that you are doing something that is cause you to lose the context and the data that was added when the window was opened
-
Bumpty bumpty… Does anyone have any insights on this?