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

HTML 5 Location Routing

5 Answers 190 Views
SPA
This is a migrated thread and some comments may be shown as answers.
Devin
Top achievements
Rank 1
Devin asked on 15 Mar 2016, 02:17 PM

Hi there,

I was wondering if it's possible to remove the # from the routing in a Kendo SPA application.   

In angularjs you set the locationProvider to use "html5" mode and it relies upon the web server being smart enough to serve any request underneath the spa to the main spa page.

For example

http://www.example.com/spa/#/main

would become

http://www.example.com/spa/main

Thanks,

Devin

5 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 17 Mar 2016, 08:59 AM
Hello,

the feature you referred to is known as pushState. The router supports it, 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
Devin
Top achievements
Rank 1
answered on 17 Mar 2016, 04:19 PM

Hmm, this doesn't seem to address my question.

I understand you can use pushState to alter the browser's page history.  

However it's my understanding that the SPA router is expecting hash tags if you want to deep link into it.

Take your Sushi example:

http://demos.telerik.com/kendo-ui/websushi/

Whenever you click on a menu item you'll get a link like

http://demos.telerik.com/kendo-ui/websushi/#/menu/1

If I start a new browser window and paste in http://demos.telerik.com/kendo-ui/websushi/#/menu/1 it'll take me to that specific menu item.

Does the router support getting rid of the hash tag to

http://demos.telerik.com/kendo-ui/websushi/menu/1

and still getting redirected to that specific menu item.

 

This explains the options in the Angularjs world:

http://stackoverflow.com/questions/16677528/location-switching-between-html5-and-hashbang-mode-link-rewriting

if that's of any help in understanding what I'm asking.

0
Devin
Top achievements
Rank 1
answered on 17 Mar 2016, 04:31 PM
Actually, after re-reading what you said I think I understand that the router supports it.  I'll play with the sushi example and post it if I get that working.
0
Devin
Top achievements
Rank 1
answered on 18 Mar 2016, 08:11 PM

So I played with the pushState mode on the router, and setup the url-rewrite in IIS rules to forward everything to spa as it should.

However whenever I refresh a page on spa/menu/1 it loads the app as it should, but it doesn't properly load the application state.

Additionally I noticed that the nice left/right sliding animation doesn't work properly either.   Am I doing something obviously wrong or is this just a case of you basically have to design the application from the beginning to use pushState vs hashTag route state?

 

I've attached my example if anyone is interested.

 

0
Petyo
Telerik team
answered on 22 Mar 2016, 09:09 AM
Hi Devin,

of you basically have to design the application from the beginning to use pushState vs hashTag route state?

This is correct - there are plenty of URLs in the scripts and links which should be changed in order for the pushState to be enabled. It is not a just a matter of changing the router configuration option.

Re-wiring an existing app may be quite complex, in fact. I would like to suggest that you start simpler, by running the snippets from the documentation, and gradually expanding from there. Please let me know if you need any further help here.

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
Devin
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Devin
Top achievements
Rank 1
Share this question
or