Routing to an absolute route (no #)

4 posts, 0 answers
  1. Dennis
    Dennis avatar
    24 posts
    Member since:
    Oct 2012

    Posted 05 Aug 2013 Link to this post

    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.
  2. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 07 Aug 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Dennis
    Dennis avatar
    24 posts
    Member since:
    Oct 2012

    Posted 08 Aug 2013 Link to this post

    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.
  5. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 09 Aug 2013 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready