Carlota
Posts: 0
Joined: Mon Aug 04, 2014 8:10 am

Load data from service before showing page

Yurii
One more question related to pagebeforeshow recommendations from above.
What I have is the following:
1.- "pagebeforeshow" JS code to hide the startpage elements
2.- "pageshow" JS code to invoke the service on startpage. The service lists a numbr of items on startpage obtained from Appery DataBase.
3.- JS code on service invocation success to show again the startpage elements

Now let's suppose I want to record if the user already selected one of the items, and if so, on next app execution I want to skip the startpage, skip service invocation and go directly to detailspage. This is the example JS

if (Apperyio.storage.selected.get("$['status']") == "TRUE") {
console.log('Item already selected. Skip to DetailsScreen');
Appery.navigateTo('MenuDetailsScreen',);
}
else {
//...
}

Where shall I better add this piece of code? In "pagebeforeshow" or in "pageshow"?

Thank you in advance!
Carlota F:

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Load data from service before showing page

HI Carlota,

The better way for that is - make this condition before navigate to this page.

But if you want or need to implement inside this page here is a brief plan:

pre

1.- "pagebeforeshow" JS code to hide the startpage elements

2.- Make condition.
2.1 If true - invoke service via JS.
2.2 If false - navigate to page(and show startpage elements).

3.- JS code on service invocation success to show again the startpage elements

/pre

Regards.

Return to “Issues”