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

how to calculate label values in an array

to get this error, open app, click clear, login use "a" as both, click menu, click pizza, click vegetarian pizza, choose 2 pizzas and click order, click checkout,

click delete on any pizza and you will see the service is not firing

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

how to calculate label values in an array

The problem is that in service mapping you do prereturn {"array": JSON.parse(value)};/pre Try instead this code prevar arr;
try {
arr = JSON.parse(value);
if ({}.toString.call(arr) !== "[object Array]") {
arr = [];
}
} catch ( e ) {
arr = [];
}
return {"array": arr};/pre

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

how to calculate label values in an array

Thanks Maryna,
that worked, error gone.

so the app is running as intended in the tester, but on device after deleting an item from checkout and the page refreshes its not reading the arrays,
the service STARUSERREAD is called when page loads, but it doesnt update.

if I go back through the app and click checkout again, it then reads the arrays in STARUSERREAD
is there another way to ensure the service is called after this code is run

$.mobile.changePage("checkout.html", { allowSamePageTransition: true,
transition: "flip", reloadPage: true });

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

how to calculate label values in an array

Hi Michael,

Try replacing:pre$.mobile.changePage("checkout.html", { allowSamePageTransition: true,
transition: "flip", reloadPage: true });/pre
With the following:preAppery.navigateTo('checkout', {
transition: 'pop'
});/pre

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

how to calculate label values in an array

No Katya,
that code deletes nothing, you click the delete button, spinner does its thing, but nothing happens, In apperyio tester and on device.

(With previous)
This is strange because I can see the total cost for the order when checkout opens, so the arrays are available to read, but the items dont show up on the screen.

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

how to calculate label values in an array

Could you clarify is the problem still exists? Looks like it was solved here https://getsatisfaction.com/apperyio/....

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

how to calculate label values in an array

Cheers Maryna,
This didnt solve the issue,

so I started a new topic with better explanation which is what you have just solved on the previous topic earlier

many thanks

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

how to calculate label values in an array

Hi Maryna,

when the code above returns the total of the labels in the arrays the number sometimes reads like this 7.9999994349, which is strange, it should read 8.

I am wondering how to round the number to the nearest 1c,

also the number displayed is like this 8,
is it possible to get the number to display 2 decimal places so read like this 8.00

thx

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

how to calculate label values in an array

Hello! Try preMath.round(totalprice).toFixed(2)/pre

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

how to calculate label values in an array

Thanks Maryna,
I am unsure where to put the code, I tried a few different ways,

on load of page,
on success of get service, and at the bottom of calculate code, as per s/s, but I am not getting a result

Image

Return to “Issues”