Page 1 of 1
how to set storage variables to a appery item in javascript
Posted: Fri Feb 20, 2015 12:16 pm
by David wyatt
hi,
im trying to set a local storage to the contents of a html component i have. ive tried
localstorage.setitem('title2',apperyio('html_uk2').html());
with title2 my storage variable and html_uk my html component
but cant get it to work
how to set storage variables to a appery item in javascript
Posted: Fri Feb 20, 2015 1:36 pm
by Evgene Karachevtsev
Hello David,
Could you please try
preApperyio.storage.storageVariable.update("$['title2']", Apperyio('html_uk2').html());/pre
You can read more about storage API here: http://devcenter.appery.io/documentat...
how to set storage variables to a appery item in javascript
Posted: Fri Feb 20, 2015 1:50 pm
by David wyatt
HI Evgene,
I tried it and still doesnt work, ive checked and all code after is stopped so i know its this line that the issue
how to set storage variables to a appery item in javascript
Posted: Fri Feb 20, 2015 4:32 pm
by Maryna Brodina
Hello!
Do you create storage variable 'title2' at Model & Storage tab? Could you post screenshot?
how to set storage variables to a appery item in javascript
Posted: Fri Feb 20, 2015 6:39 pm
by David wyatt
how to set storage variables to a appery item in javascript
Posted: Sat Feb 21, 2015 4:30 am
by M&M
Hi David,
If what you posted in your main question is the actual command you used
code
localstorage.setitem('title2',apperyio('html_uk2').html());
/code
then probably it's because of the "apperyio" or "setItem" method because JS is case-sensitive.
So you can try something like this
Split that code a bit more in the sense that
Write the contents of the HTML component to the console using console.log
If it has contents then try setting the LSV to those contents using
code
var html_component_contents = apperyio('html_uk2').html(); // Check if this is supposed to be Apperyio('html_uk2').html() or Appery('html_uk2').html() - case sensitive
console.log(html_component_contents); // check if contents are shown
localstorage.setItem('title2',html_component_contents); // setItem - case-sensitive
/code
Another thing that you can check is that is it some special character in your html content that is causing the LSV to not store the contents. Try some encoding to check that part too. If it is the special character, then you can encode it while saving, and decode it easily after retrieving
how to set storage variables to a appery item in javascript
Posted: Sat Feb 21, 2015 5:19 pm
by David wyatt
HI M&M,
thanks for your help but i think now the issue is around the contents of the html component as ive tried events set local storage and have the same issue.
The html component is set from a rss feed service, the strange thing is when you set the local storage from pressing a label component inside the grid it works (the grid is linked to the rss array but ive set it to hide elements to only show the second article from the feed) , when you action it from outside it doesnt show anything.
hope that makes sense
how to set storage variables to a appery item in javascript
Posted: Sat Feb 21, 2015 5:25 pm
by David wyatt
how to set storage variables to a appery item in javascript
Posted: Sat Feb 21, 2015 6:49 pm
by David wyatt
managed to get it working now, thank you M&M