Page 5 of 8

how to calculate label values in an array

Posted: Fri Nov 22, 2013 2:07 pm
by Michael4771079

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


how to calculate label values in an array

Posted: Fri Nov 22, 2013 2:36 pm
by Maryna Brodina

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


how to calculate label values in an array

Posted: Fri Nov 22, 2013 3:16 pm
by Michael4771079

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 });


how to calculate label values in an array

Posted: Fri Nov 22, 2013 10:09 pm
by Kateryna Grynko

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


how to calculate label values in an array

Posted: Fri Nov 22, 2013 10:22 pm
by Michael4771079

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.


how to calculate label values in an array

Posted: Mon Nov 25, 2013 6:49 pm
by Maryna Brodina

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


how to calculate label values in an array

Posted: Mon Nov 25, 2013 6:56 pm
by Michael4771079

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


how to calculate label values in an array

Posted: Fri Dec 06, 2013 1:41 pm
by Michael4771079

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


how to calculate label values in an array

Posted: Fri Dec 06, 2013 2:34 pm
by Maryna Brodina

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


how to calculate label values in an array

Posted: Fri Dec 06, 2013 3:14 pm
by Michael4771079

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