Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to store data using localstorage?
    primarykey
    data
    text
    <p>i'm trying to get the favorites list using localstorage. I have a listview with number of items when i clicked on the item it opens and contains some data.In the same page i have a button with <code>"Bookmark"</code>. when i clicked on that button that particular page has to added in that favourites list. When i'm trying to get the list of favorites it doesn't store any data. </p> <p>HTML file:</p> <pre><code>&lt;!-- Favourites page --&gt; &lt;div data-role="page" id="fav"&gt; &lt;div data-role="header"&gt; &lt;h1&gt;Favorites&lt;/h1&gt; &lt;/div&gt; &lt;div data-role="content"&gt; &lt;ul id="favoritesList" data-inset="true" data-filter="true"&gt;&lt;/ul&gt; &lt;/div&gt; &lt;div data-role="footer" data-position="fixed"&gt; &lt;a href="#home" data-icon="home" data-iconpos="left"&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Js file:</p> <pre><code>&lt;a href="" data-role="button" class="addToFavoritesDiv"&gt;Bookmark&lt;/a&gt; $(".addToFavoritesDiv").click(function() { var path = $.mobile.activePage.data('url'); //alert(path); //var store = localStorage.path; s += "&lt;li&gt;&lt;a href=\"index.html?id="+ localStorage.path +"\"&gt;&lt;/a&gt;&lt;/li&gt;"; $('#favoritesList').append(s); //alert("appended"); $('#favoritesList').listview('refresh'); }); $("#fav").on('click', function(event){ //get our fav var fav; var favs; for (var i = 0; i &lt; localStorage.length; i++) { fav = favs[i]; } s += "&lt;li&gt;&lt;a href=\"index.html?id=""\" class="item"&gt;&lt;/a&gt;&lt;/li&gt;"; $('#favoritesList').append(s); addToStorage(fav); }); function addToStorage(favList) { $(".item").on('click', function (){ var i = $('.item').index(this); console.log(i); localStorage['results'] = JSON.stringify(favList[i]); storedItem = (localStorage['results']) ; console.log(storedItem); alert("this post was added to local storage"); //retrieve list item var retrievedItem = localStorage.getItem(['results']); console.log( 'retrieved: ' + retrievedItem); } </code></pre> <p>can anyone help me to get the favorites list.</p> <p>Thanks in Advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload