Page 1 of 1

changing container background on the basis of a local storage variable

Posted: Wed Nov 27, 2013 10:38 am
by ciccio

hello, in my app i have a list of products and on list item click event i save a local storage variable and i navigate to a details page.
i uploaded to the image assets some images named with the same id saved on the list item click event
eg: for the list item with the id 1 i have an image assett named bkg1.jpg.
what i would like to do is to have different containers's background for different details pages.
i tried to run the following JS on load event of the details page:
JS1:
codevar image = localStorage.getItem('id_prodotto')+".jpg&quot
var bkg = Appery.getImagePath(image);
Appery('mobilecontainer1').css('background-image','url("' + bkg + '")'); /code

or JS2:
codevar image = "'"+localStorage.getItem('id_prodotto')+".jpg'&quot
Appery('mobilecontainer1').css('background-image','url("' + Appery.getImagePath(image) + '")'); /code

but none of them work.

Could you help me?


changing container background on the basis of a local storage variable

Posted: Wed Nov 27, 2013 12:04 pm
by Kateryna Grynko

Hi,

We'll check this.


changing container background on the basis of a local storage variable

Posted: Wed Nov 27, 2013 12:10 pm
by ciccio

i checked again and on the JS2 example there was a problem with "' ' " in var image.
i tested codevar image = localStorage.getItem('id_prodotto')+".jpg&quot
Appery('mobilecontainer1').css('background-image','url("' + Appery.getImagePath(image) + '")'); /code
but it still doesn't work and on the console i get:
Resource interpreted as Image but transferred with MIME type text/html: "http://appery.io/404.htm".


changing container background on the basis of a local storage variable

Posted: Wed Nov 27, 2013 2:27 pm
by Kateryna Grynko

Sorry, this is a small bug. Will be fixed soon. For now, replace 'mobilecontainer1' with 'mobilecontainer' please.