This is a migrated thread and some comments may be shown as answers.

Problem with consecutive calls to app.navigate("#:back")

6 Answers 121 Views
Application
This is a migrated thread and some comments may be shown as answers.
Ron
Top achievements
Rank 1
Veteran
Ron asked on 18 May 2015, 01:58 PM

Hello,
In our application, in case the user clicked a certain button, we need to go back two screens. We do this with the following code:

                    app.navigate("#:back");
                    setTimeout(function(){
                        app.navigate("#:back");//to budget edit
                    }, 0);
                }
Testing this code works well on Chrome. It also works well in our tests on iPhone. However in our tests on Android (Nexus 7) it fails and only the first app.navigate("#:back") is executed. Meaning our app fails to bring the user to the correct view. Do you have any idea what might be the cause and how can we handle it?

Thanks,

Ron.

6 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 20 May 2015, 07:34 AM
Hi Ron,

you can use the native browser history API - like history.go(-2);

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ron
Top achievements
Rank 1
Veteran
answered on 26 May 2015, 08:10 PM

Thanks Petyo - indeed it seems to do the trick.

Can/Should we also use the browser history API in order to clean its cache? Our app is based on sessions and currently the history is accumulated all the time. Meaning if one user logs into the app and then logs out clicking the back button will bring views from her expired session, and it is wrong. So we are looking for a way to clean the history when ever a new session is starting. Should we use this API as well?

Ron.

0
Petyo
Telerik team
answered on 28 May 2015, 06:52 AM
Hello,

I am not sure to which history API part you refer to, but I am not aware of means to clear cache and/or remove entries from it. In general, you may use the beforeShow view event handler to detect expired logins and redirect the user accordingly. 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ron
Top achievements
Rank 1
Veteran
answered on 28 May 2015, 02:53 PM

The problem is seen on android device as we have a back button there.

 

When the user is using it she might switch between users - if she is using to exit the app using the back button it results with us seeing views from the previous users until we complete going back the entire history. 

This is also relevant for a one user scenario - if he exit the app using the home button and later uses the back button, again he will go over all his previous sessions.

 

Basically, we were wondering if there is a way to clear the views history.

0
Petyo
Telerik team
answered on 01 Jun 2015, 03:22 PM
Hello,

I am not aware of any means to clear the browser history. Did you try the suggestion I provided? the beforeshow filter may help in this case. 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ron
Top achievements
Rank 1
Veteran
answered on 02 Jun 2015, 02:20 PM

Hi Petyo,

We are well familiar with using beforeShow however this could not assist in the described problem as the Android back button will still walk us thru older sessions (even if we see partial views because the beforeShow knows it's a different session).

We eventually handled it by using history.go(-(history.length - 1)) as the following link suggested:
http://stackoverflow.com/questions/14920806/is-it-possible-to-onclick-history-clear

(Remark: we actually found out we need to use history.length - 3 for it to work well in our case)

Tags
Application
Asked by
Ron
Top achievements
Rank 1
Veteran
Answers by
Petyo
Telerik team
Ron
Top achievements
Rank 1
Veteran
Share this question
or