Lawnchair persistant localstorage example JSON


/ Published in: JavaScript
Save to your folder(s)

Default adapter saves to DOM.


Copy this code and paste it in your HTML
  1. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
  2. <script type="text/javascript" src="js/lawnchair-0.6.1.min.js"></script>
  3.  
  4. <script>
  5. $(document).ready(function() {
  6. var viewData = new Lawnchair({name:'testing'}, function(viewData) {
  7.  
  8. var me = [{"name":"ie7","y":12.8},{"name":"ie9","y":19.8},{"name":"opera","y":7.4},{"name":"firefox","y":17.4},{"name":"firefox3","y":10.6}];
  9.  
  10. viewData.save({key:'data',options:me}, function(obj){
  11. console.log(obj)
  12. });
  13.  
  14. viewData.get('data', function(me) {
  15. console.log(me.options);
  16. });
  17.  
  18. //console.log(store.get(me));
  19.  
  20. });
  21. });
  22. </script>
  23.  
  24. //localstorage, data = "{"options":[{"name":"ie7","y":12.8},{"name":"ie9","y":19.8},{"name":"opera","y":7.4},{"name":"firefox","y":17.4},{"name":"firefox3","y":10.6}]}"

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.