Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

selectmenu undefined when mapped from localstorage

Hi,
I have a service where I created a modelstorage and the selectmenu is comming on the screen as undefined.

I am including some screenshots it may help to discover what mistake I have made.

Here is the collection,
modelstorage,
mapping to localstorage
result in localstorage,
mapping to page, the js used in mapping for selectmenu and the result is undefined, the mapping js is from the old builder, without the js nothing shows on the screen.

Does this js need to be altered for the new builder?
Or is ther something else wrong with this setup?

there are no errors in console

If theres anything else I can show you please ask

thanks

Image

Image

Image

Image

Image

Image

js used in mapping to selectmenu

codefunction strRepresentationToObject(str) {
str = str.slice(1, -1);
var i, len, obj={}, tmp, arr = str.split(', ');
for (i = 0, len = arr&#46;length; i < len; i++) {
tmp = arr&#46;split('=');
obj[tmp[0]] = tmp[1];
}
return obj;
}
var valuesArray;
try {
valuesArray = JSON&#46;parse(value);
if ({}&#46;toString&#46;call(valuesArray) !== "[object Array]") {
valuesArray = [];
}
} catch ( e ) {
valuesArray = [];
}
var i, len, obj, $element = $(element);
$element&#46;empty();
for (var i = 0, len = value&#46;length; i < len; i++) {
obj =strRepresentationToObject(value);
$element&#46;append('<option rerender="chickenpizzaselectmenu" value="' + obj['price'] + '">' + obj['size'] + '</option>');
}
return true;/code

Image

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

selectmenu undefined when mapped from localstorage

Hi something I forgot,
not sure if its revelant, the following js is static in the app

codefunction save(item, varName) {
try {
var arr = JSON&#46;parse(localStorage&#46;getItem(varName));
if ({}&#46;toString&#46;call(arr) !== "[object Array]") {
arr = [];
}
} catch ( e ) {
arr = [];
}
arr&#46;push(item);
localStorage&#46;setItem(varName, JSON&#46;stringify(arr));
}

function myload(varName) {
try {
var arr = JSON&#46;parse(localStorage&#46;getItem(varName));
if ({}&#46;toString&#46;call(arr) !== "[object Array]") {
arr = [];
}
} catch ( e ) {
arr = [];
}
}
/code

thanks

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

selectmenu undefined when mapped from localstorage

Hi Michael -

As I assume this issue is related to your app "anglo pizza", am I correct?

We are working on it, and we will post an update when we get some news from our developers.

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

selectmenu undefined when mapped from localstorage

Ok lllya,
thanks for that,
yes this issue is another issue from anglo upgrade,
I raised it as time is running short, and until I can advance I dont know what other problems I may uncover.

thanks for the reply

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

selectmenu undefined when mapped from localstorage

I forgot to mention
once logged in to app (use "a" as login and pass)
click new order btn
from menu click pizza
then click vegetarian pizza

in builder the page name is "anglovegpizza"

result has changed somehow, maybe another tweak your end,
mapping is still the same but the selectmenu is completely empty

Image

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

selectmenu undefined when mapped from localstorage

Hello Michael,

We managed to reproduce this and are working on it.

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

selectmenu undefined when mapped from localstorage

Thanks for telling me Evegene

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

selectmenu undefined when mapped from localstorage

Hello,

1) You need to use mapping instead of your JavaScript code. You copy and paste new objects incorrect.

2) code return true;/code

Returning value should be a number

3) Add after first mapping for this service JavaScript code that saves properly value and name to the LSV, don't forget to create those fields in LSV at storage and models, and then use this LSV in second mapping, it will be much easier, than cloning templates tags and append them in right place at the page.

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

selectmenu undefined when mapped from localstorage

Hi,
Im sorry I really dont understand your awnser.
The sizeandprice array is in the Json in localstorage
I just need to map it to the selectmenu.
I need to keep the app logic that already exists

Is there an example or docs about mapping an array from a Json to a selectmenu in a grid?

yhanks

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

selectmenu undefined when mapped from localstorage

This is an ugrade to new builder,
very disapointed in the level of support.
New build would be outside of your support, but update to new builder with a published app used to be alot better.

very pissed off

Return to “Issues”