Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jimrhoskins/knockout.localStorage

localStorage persistence for knockout.js
https://github.com/jimrhoskins/knockout.localStorage

Last synced: 2 months ago
JSON representation

localStorage persistence for knockout.js

Awesome Lists containing this project

README

        

# knockout.localStorage

knockout.localStorage is a plugin for knockout.js which allows observable
values to be saved into localStorage.

# Usage
You can make a ko.observable or ko.observableArray automatically persist
its value to localStorage, but adding a second options argument, and
specifying `{ persist: "localStorageKey"}` where `localStorageKey` is
the key to use when storing the value to localHost

var viewModel = {
name: ko.observable(),

nameDefault: ko.observable('Jim'),

namePersist: ko.observable(null, {persist: 'namePersist'}),

nameDefaultPersist: ko.observable('James', {persist: 'nameDefaultPersis'})

}

ko.applyBindings(viewModel);