saving an array in localstorage
Hi!
Please try this code save(Tiggzi('component_name').attr('text'), 'variable_name') instead of save(Tiggzi('component_name').text(), 'variable_name')
Let us know if it helps
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
Hi!
Please try this code save(Tiggzi('component_name').attr('text'), 'variable_name') instead of save(Tiggzi('component_name').text(), 'variable_name')
Let us know if it helps
Hi Marina,
this is the result
variable_favourites
"["","","","","","","","","","",null,null]"
Add one more part of JS to JS asset. Whole JS should look like this:
codefunction setSelectMenuOptions(select, options) {
select.children().each(function() {$(this).remove()});
for(i=0; i<options.length; i++) {
var value = options;
var newOption = $('<option value="'+value+'">'+value+'</option>');
select.append(newOption);
}
select.refresh();
}
function save(item, varName) {
var arr = JSON.parse(localStorage.getItem(varName));
if(arr == null) {
arr = new Array();
}
arr.push(item);
localStorage.setItem(varName, JSON.stringify(arr))
}
function myload(varName) {
var arr = JSON.parse(localStorage.getItem(varName));
if(arr == null) {
arr = new Array();
}
return arr;
}/code
Put this code on button to save array
codesave(Tiggzi('mobiletextinput1').val(), 'variable_name')/code
Put this code on button to update valued in select menu
codesetSelectMenuOptions(Tiggr('mobileselectmenu2'), myload('variable_name'));/code
On scrin Load run Customm JS to refresh values
codelocalStorage.setItem('variable_name', null);code
/code/code
Sorry for this Marina,
do you mean in custom java instead of this
dofunction save(item, varName) {
var arr = JSON.parse(localStorage.getItem(varName));
if(arr == null) {
arr = new Array();
}
arr.push(item);
localStorage.setItem(varName, JSON.stringify(arr))
}
function myload(varName) {
var arr = JSON.parse(localStorage.getItem(varName));
if(arr == null) {
arr = new Array();
}
return arr;
}
Yes:)
no Marina, no change on select menu, result in firebug local storage
variable_favourites "null"
-
Please check components name, are they correct?
no luck Marina,
I followed the detail, but I can't get it to work
What builder do you use?
the new builder