Skip to content

dat-boris/knockout.localStorage

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'}),

  // any changes to localStorage will be propagated back to the variable
  synclocal : ko.observable('Jamie', {persist: 'nameTestLocal', synclocal : true, pollfreq : 500 })
}

ko.applyBindings(viewModel);

About

localStorage persistence for knockout.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 86.3%
  • Shell 13.7%