Quantcast
Viewing all articles
Browse latest Browse all 8068

Alloy Model resets every window refresh to last element input and deletes stored data

Im trying to leer Alloy Models but i have a situation that i can't solve.

this is the code that im using to store a model data, using localStorage (html5) but every time i refresh the browser window the data seems to be resetet. to the very last data that i input, here's the code

var library = Alloy.Collections.book;
 
 function add() {
 
 var book = Alloy.createModel('book', {
 name: $.txt.value,
 author : 'douglas'
 });
 library.add(book);
 book.save();
 }
 
 library.fetch();
 $.win.open();

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>