uil
uil copied to clipboard
Option to persist value to localStorage
For convenience, it would be nice to have persistent values on controls. When the user reloads the page, the values can be loaded back in from localStorage.
ui.add('title', { name:'Title', persist: true});
yes sound like saving systeme, have to make some research about
I'm not sure whether datastorage needs to be part of an ui-library. Why not just use the callbacks. For example, something like this:
var data = {}
function load(){
var d = window.localStorage.getItem('data')
if( d ) data = JSON.parse(d)
}
function save(key,value){ // key will be preloaded by bind(..) later
data[key] = value
window.localStorage.setItem('data', JSON.stringify(data) )
}
// init UIL
load()
for( var key in data )
ui.add(i,{name:key, value: data[key], callback: save.bind(null,key) })