how to set storage variables to a appery item in javascript

This forum contains topics that were moved from Get Satisfaction
David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

how to set storage variables to a appery item in javascript

Post 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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

how to set storage variables to a appery item in javascript

Post 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...

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

how to set storage variables to a appery item in javascript

Post 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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

how to set storage variables to a appery item in javascript

Post by Maryna Brodina »

Hello!

Do you create storage variable 'title2' at Model & Storage tab? Could you post screenshot?

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

how to set storage variables to a appery item in javascript

Post by David wyatt »

think i have
ive attached local storage, component and the javascript to show you
Image Image Image

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

how to set storage variables to a appery item in javascript

Post 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

  1. 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

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

how to set storage variables to a appery item in javascript

Post 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

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

how to set storage variables to a appery item in javascript

Post by David wyatt »

David wyatt
Posts: 0
Joined: Mon Sep 15, 2014 7:12 pm

how to set storage variables to a appery item in javascript

Post by David wyatt »

managed to get it working now, thank you M&M

Post Reply