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

Using history.replaceState to manage back stack / back button navigation

3 Answers 506 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Robby Parker
Top achievements
Rank 1
Robby Parker asked on 08 Sep 2015, 03:13 PM

I have a Kendo UI application flow where I don't want the user to be able to step back into a particular set of views (ie, a couple of 'create' views that lead to the 'completed record' view - the user should not re-access those specific create views). This is for a mobile app if that makes a difference.

I know that Kendo can use window.history features to some degree, but it looks like they have only implemented pushState (http://docs.telerik.com/kendo-ui/api/javascript/router#configuration-pushState), but I believe I would need the replaceState method.

Is there a way to take some manual control temporarily without breaking off from the back stack/backbutton widget?

3 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 09 Sep 2015, 12:51 PM

Hello Robby,

 

the router proxies the replace calls through its replace method. The history has one, too.

 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Robby Parker
Top achievements
Rank 1
answered on 15 Sep 2015, 03:05 PM

Thanks Petyo.

I have been trying to work with the router object, but I'm not sure I am understanding it - I either ​get an error message of "Uncaught TypeError: Cannot read property 'stop' of undefined" or not get a result at all.

1) I create a router object:

router = new kendo.Router({ pushState: true, root: "/", hashBang: true });

2) If I call replace on the view that I want to remove using it's name I don't seem to get anything to happen.

For example, if my flow is '#thePreviousView' -> '#theCurrentView' -> '#theNextView':

I call router.replace("#theCurrentView"); while viewing '#theCurrentView' 

Then if I go to '#theNextView', and then use a data-role="backbutton", I return to '#theCurrentView'. I would expected to go to '#thePreviousView'

3) If it matters, I am using app.navigate (app = new kendo.mobile.Application) and call app.navigate from kendoTouch tap events and occasionally from inside of ajax.success call backss. Will I need to use router.navigate for everything I want to replace? Should I be using router.navigate for all navigation events?

0
Petyo
Telerik team
answered on 17 Sep 2015, 06:08 AM

Hello Robby,

 

using the router instance directly is not necessary if you have a mobile application instance - it has a replace method, too. 

 

Notice that you if you want to remove B from A -> B -> C, you should call replace(C) when on B. With that, C will replace B, effectively removing it from the history stack.

 

Navigating to the same point (calling replace B when on B) has no effect. 

 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
General Discussions
Asked by
Robby Parker
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Robby Parker
Top achievements
Rank 1
Share this question
or