i'm trying favorites list using localstorage. have listview number of items when clicked on item opens , contains data.in same page have button "bookmark"
. when clicked on button particular page has added in favourites list. when i'm trying list of favorites doesn't store data.
html file:
<!-- favourites page --> <div data-role="page" id="fav"> <div data-role="header"> <h1>favorites</h1> </div> <div data-role="content"> <ul id="favoriteslist" data-inset="true" data-filter="true"></ul> </div> <div data-role="footer" data-position="fixed"> <a href="#home" data-icon="home" data-iconpos="left"></a> </div> </div>
js file:
<a href="" data-role="button" class="addtofavoritesdiv">bookmark</a> $(".addtofavoritesdiv").click(function() { var path = $.mobile.activepage.data('url'); //alert(path); //var store = localstorage.path; s += "<li><a href=\"index.html?id="+ localstorage.path +"\"></a></li>"; $('#favoriteslist').append(s); //alert("appended"); $('#favoriteslist').listview('refresh'); }); $("#fav").on('click', function(event){ //get our fav var fav; var favs; (var = 0; < localstorage.length; i++) { fav = favs[i]; } s += "<li><a href=\"index.html?id=""\" class="item"></a></li>"; $('#favoriteslist').append(s); addtostorage(fav); }); function addtostorage(favlist) { $(".item").on('click', function (){ var = $('.item').index(this); console.log(i); localstorage['results'] = json.stringify(favlist[i]); storeditem = (localstorage['results']) ; console.log(storeditem); alert("this post added local storage"); //retrieve list item var retrieveditem = localstorage.getitem(['results']); console.log( 'retrieved: ' + retrieveditem); }
can me favorites list.
thanks in advance.
Comments
Post a Comment