<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Cannot save and load localstorage value in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Cannot-save-and-load-localstorage-value/m-p/999795#M29675</link>
    <description>&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I'm trying to save a variable to local storage and load it on app start.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Here is the code for saving and is the result of a flipswitch onchange event.&lt;/P&gt;

&lt;P&gt;function setFixView() {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; if ($('#af-flipswitch-0').is(":checked"))&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; window.localStorage.setItem("showallfixtures", "yes");&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } else {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; window.localStorage.setItem("showallfixtures", "no");&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;
	};&lt;/P&gt;

&lt;P&gt;A breakpoint in the debug shows this is working correctly.&lt;/P&gt;

&lt;P&gt;Here is the code for retrieving the variable:-&lt;/P&gt;

&lt;P&gt;&amp;nbsp;$( document ).ready(function() {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; console.log("Starting App");&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var showfixtures = window.localStorage.getItem("showallfixtures");&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; console.log("Shall we show the fixtures".showfixtures);&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var fixturestate = document.getElementById("af-flipswitch-0");&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(showfixtures == 'yes') {&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $('af-flipswitch-0').attr('checked','checked');&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;

&lt;P&gt;I am getting the following error at the console.log("Shall we show the fixtures".showfixtures); line&lt;/P&gt;

&lt;P&gt;Uncaught TypeError: Cannot read property 'getItem' of undefined VM5353 index.html:69 (anonymous function)&lt;/P&gt;

&lt;P&gt;The idea was to use Console.log just to show the variable had been retrieved, but ultimately I need to set the flipswitch to the previous selection.&lt;/P&gt;</description>
    <pubDate>Mon, 30 Mar 2015 10:28:53 GMT</pubDate>
    <dc:creator>Nick_F_2</dc:creator>
    <dc:date>2015-03-30T10:28:53Z</dc:date>
    <item>
      <title>Cannot save and load localstorage value</title>
      <link>https://community.intel.com/t5/Software-Archive/Cannot-save-and-load-localstorage-value/m-p/999795#M29675</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I'm trying to save a variable to local storage and load it on app start.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;Here is the code for saving and is the result of a flipswitch onchange event.&lt;/P&gt;

&lt;P&gt;function setFixView() {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; if ($('#af-flipswitch-0').is(":checked"))&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; window.localStorage.setItem("showallfixtures", "yes");&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } else {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; window.localStorage.setItem("showallfixtures", "no");&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;
	};&lt;/P&gt;

&lt;P&gt;A breakpoint in the debug shows this is working correctly.&lt;/P&gt;

&lt;P&gt;Here is the code for retrieving the variable:-&lt;/P&gt;

&lt;P&gt;&amp;nbsp;$( document ).ready(function() {&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; console.log("Starting App");&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var showfixtures = window.localStorage.getItem("showallfixtures");&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; console.log("Shall we show the fixtures".showfixtures);&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var fixturestate = document.getElementById("af-flipswitch-0");&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(showfixtures == 'yes') {&amp;nbsp;&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $('af-flipswitch-0').attr('checked','checked');&lt;BR /&gt;
	&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;

&lt;P&gt;I am getting the following error at the console.log("Shall we show the fixtures".showfixtures); line&lt;/P&gt;

&lt;P&gt;Uncaught TypeError: Cannot read property 'getItem' of undefined VM5353 index.html:69 (anonymous function)&lt;/P&gt;

&lt;P&gt;The idea was to use Console.log just to show the variable had been retrieved, but ultimately I need to set the flipswitch to the previous selection.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2015 10:28:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Cannot-save-and-load-localstorage-value/m-p/999795#M29675</guid>
      <dc:creator>Nick_F_2</dc:creator>
      <dc:date>2015-03-30T10:28:53Z</dc:date>
    </item>
    <item>
      <title>Sorry the error appears at</title>
      <link>https://community.intel.com/t5/Software-Archive/Cannot-save-and-load-localstorage-value/m-p/999796#M29676</link>
      <description>&lt;P&gt;Sorry the error appears at&amp;nbsp;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;var showfixtures = window.localStorage.getItem("showallfixtures"); not per my original post.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2015 12:47:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Cannot-save-and-load-localstorage-value/m-p/999796#M29676</guid>
      <dc:creator>Nick_F_2</dc:creator>
      <dc:date>2015-03-30T12:47:48Z</dc:date>
    </item>
    <item>
      <title>Dear Nick,</title>
      <link>https://community.intel.com/t5/Software-Archive/Cannot-save-and-load-localstorage-value/m-p/999797#M29677</link>
      <description>&lt;P&gt;Dear Nick,&lt;/P&gt;

&lt;P&gt;Try and change&amp;nbsp;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;window.localStorage.getItem("showallfixtures") to localStorage.getItem("showallfixtures")&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;Do the same to the setitem section.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Apr 2015 16:41:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Cannot-save-and-load-localstorage-value/m-p/999797#M29677</guid>
      <dc:creator>Michael_O_</dc:creator>
      <dc:date>2015-04-04T16:41:43Z</dc:date>
    </item>
  </channel>
</rss>

