Note that there are some explanatory texts on larger screens.

plurals
  1. POLocalstorage and saving session state
    text
    copied!<p>I am making a webapp, that uses mobiscroll as a number counter. The numbers are saved via a submit button below it. The problem I have is whenever the user presses the home button, when the webapp is reloaded, it resets the number list. I figured it would be a good idea to save the value to localstorage,and recall it when the app is reopened. Now that's where I am stuck.</p> <p>Here is the function for the button press that works fine:</p> <pre><code>&lt;script type="text/javascript"&gt; function save_it() { //Save the scroll value for later var scrollsave = $('#i').scroller('getValue'); localStorage.setItem("scrollsave", scrollsave); localStorage.saveServer } &lt;/script&gt; </code></pre> <p>I have a function further up, that is giving me trouble, and refusing to work proper, I have tried the following methods:</p> <p>My first attempt to assign</p> <pre><code>&lt;script type="text/javascript"&gt; $(function () { var scrollstate = localStorage["scrollsave"]; if (scrollstate != null) { $('#i').scroller('setValue', scrollstate); } }); &lt;/script&gt; </code></pre> <p>I get an error of, Object x,x,x,x has no method 'join'. </p> <p>Second attempts to convert to array and back, but no luck.</p> <pre><code>var oldscroll = localStorage.getItem["scrollsave"]; var finalsaved = SON.parse(oldscroll); if (finalsaved != null) { $('#i').scroller('setValue', finalsaved); </code></pre> <p>The documentaion on mobiscroll is here <a href="http://docs.mobiscroll.com/22/mobiscroll-core" rel="nofollow">http://docs.mobiscroll.com/22/mobiscroll-core</a> . And it says, "scroller values from the data parameter passed as array". </p> <p>My key, scrollsave is stored with a value of 1,2,1,1 . Which seems to meet the correct formatting to throw into the mobiscroll part.</p> <p>I have a feeling there is something trivial I am overlooking, but I can't figure out what.</p>
 

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