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

Routing to an absolute route (no #)

3 Answers 120 Views
SPA
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 2
Dennis asked on 05 Aug 2013, 11:18 AM
Hi,

I've been playing around with the SPA parts.

Let me explain how our app works. We are using ASP MVC / Web API on the server. We are also using Microsofts unobtrusive ajax library to load between different pages in our SPA. So when clicking a link to an entierly different page (for instance moving from Calendar to Cotacts) an ajax request is sent to the server to fetch the contents of the main content area. The request returns just the main area's HTML and that gets renderded without having to reload the surrounding menus and all the script / css files on each page change. The server is smart enough to know if its a ajax request. If its not the html for the request it returns gives out the whole layout with the menus, HTML head and everything.  so a direct link to any page renders normaly, and moving within the application just uses ajax to update main content area.

So when unobtrusive ajax on a click pulls data for a new content area and renders it we also need to change the history state. We are just using vanilla History api with no legacy fallback. We were wondering if we could replace that with the router? Does it support legacy fallback is the first question? The second one is can I use the router to absolutely change an url. So no "#". The way I see it, if I haven't missed anything the router is usefull for tracking states on the current page, but not for linking multiple different pages that make up our more complex SPA.

3 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 07 Aug 2013, 07:21 AM
Hello Dennis,

The router currently features pushState support (which is not yet undocumented) which also includes legacy fallback to the fragment part of the URL (using #). 

var router = new kendo.Router({ pushState: true });
 
// ...

Please give this approach a try and let us know if it works for your case. 

Once instantiated, the router operates either in pushState or in fragment mode. I think that you can also trick it into using both (although I am not sure if this needed). by setting url with # in it. We have not tested such approach, though. 

Regards,

Petyo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dennis
Top achievements
Rank 2
answered on 08 Aug 2013, 08:36 AM
Nope even when its instantised like this once I use navigate it just appends a # and the url after that. I tried sending it both an absolute and relative url. It acts the same. But I also noticed navigate doesnt support other features of the History API we use, like the stateObject so I don't think we would be able to implement it in the current state.
0
Petyo
Telerik team
answered on 09 Aug 2013, 08:15 AM
Hi,

The stateObject  is not supported, indeed. The pushstate configuration option was introduced in our Q2 release - are you using this version?

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