Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
localStorage persistence for knockout.js
JavaScript Shell
Branch: master
Failed to load latest commit information.
build Initial Commit
examples Initial Commit
support Initial Commit
.gitignore Initial Commit
LICENSE Initial Commit
README.md Initial Commit
knockout.localStorage.js Now using ko.toJSON to stringify values. via @cslarson

README.md

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);
Something went wrong with that request. Please try again.