Search code examples
javascriptmodel-view-controllertitaniumtitanium-mobile

Titanium Saving the state of the last window viewed


How would i go about saving the state of the last viewed window of my application?

I have been trying titanium.app.properties with no luck. I am using MVC so everything is split up into separate files. Would I go about this by making a couple of global variables in the model, and calling them with app.properties? If you can help, could you please provide an example?

Thanks for any help <3


Solution

  • So i have been able to get it to work by simply doing as stated in another answer. for anyone interested It goes as follows

    //This decides what screen it should open
    var lastwin = Ti.App.Properties.getString("lastwin");
    
    if ( lastwin == 'SavedList'){
        SavedList.open();
        SavedListNav.open();
    }
    else if (lastwin == 'tomList'){
        tomList.open();
        TomNav.open();
    }
    else if (lastwin == 'Recipes'){
        Recipes.open();
        RecipesNav.open();
    }
    else MainMenu.open();
    
    //in each function that leads to the specific screen you want do it like so
    SavedListsBTN.addEventListener('click', function(e){
        Ti.App.Properties.setString("lastwin", 'SavedList');
        SavedList.open();
        SavedListNav.open();
        MainMenuNav.close();
        MainMenu.close();
    });