Roger
Posts: 0
Joined: Fri Mar 29, 2013 1:10 pm

In PageShow event can I determine what Page I am coming from?

How can I determine what Page the app is coming from during a PageShow event? For example, during PageShow I am executing a service call to get data. When I click on the data I will navigate to another page. If I then click the back button to return to original page the PageShow will fire again and execute that same service call when it is not needed. Is there a way to determine when I am coming from before executing my service call?

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

In PageShow event can I determine what Page I am coming from?

Hello! You can check previous page name on Page Show event using the following JS:
codevar prevPageName = '';
if(arguments[1]["prevPage"][0]) {
prevPageName = $(arguments[1]["prevPage"][0]).attr("dsid");
}/code

There is also another way - you can create local storage variable and before service call check - if variable is set then call the service, else - do not call the service.

Roger
Posts: 0
Joined: Fri Mar 29, 2013 1:10 pm

In PageShow event can I determine what Page I am coming from?

That works great. I had something working with local storage but like this method better.

Thanks for all the help.

Sam6522984
Posts: 0
Joined: Thu Dec 26, 2013 2:35 pm

In PageShow event can I determine what Page I am coming from?

Hi there

I tried the code you provided Maryna, unfortunately I get an exception because arguments[1] is undefined. Do you have an idea what's going wrong?

Thanks for your help
Samuel

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

In PageShow event can I determine what Page I am coming from?

Hello Sam,

Unfortunately you can't do this:
http://stackoverflow.com/questions/40...
But you can write name of the page in localStorage, and after that you can read it on the next page.

Sam6522984
Posts: 0
Joined: Thu Dec 26, 2013 2:35 pm

In PageShow event can I determine what Page I am coming from?

Hi Evgene

Thank you for your suggestion, I'll work with the localStorage approach.

Return to “Issues”