Appframe Knowledge Base

1 hits

Using af.common.localStorage to save UI state

/* If localStorage is not supported by your browser,
   the settings will be kept in memory and reset on reload.
   If you need to check if your settings will be persisted,
   you can use this command to test for support: */

// > true

/* When getting a setting and the value does not exist
    you can specify a default value as the second parameter
    and that value will be returned if no data is in the localStorage */

af.common.localStorage.get("mySetting", "myDefaultValue");
// > "myDefaultValue"

/* Values that are stored in localStorage gets stored per article
    by reading the value, so make sure this is correct */

af.common.localStorage.set("mySetting", "someOtherValue");
// > undefined

/* You can also remove individual keys */

// > true

/* Or you can clear everything beeing stored for the active article */

// > undefined

common web · Perma link post comment Posted by: Jan Henrik Høiland Meling (14-mai-2012)