Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with getting hash routing to work #82

Open
thasmo opened this issue Jun 25, 2013 · 6 comments
Open

Problem with getting hash routing to work #82

thasmo opened this issue Jun 25, 2013 · 6 comments

Comments

@thasmo
Copy link

thasmo commented Jun 25, 2013

Hi there!

I'm using the hash routing plugin for IE < 10 and I'm not sure if it's working like it should. Whenever I click a link in my app, the whole URL gets updated instead of the hash only. After the URL changes (and the page gets reloaded) Davis.js updates the hash with the current URL, because I've set "normalizeInitialLocation" to "true".

So in my oppinion when clicking a link Davis.js should only update the hash and trigger the routing - no?

Or is it absolutely needed to set links in my app with a prepended "#" in the href attribute? What I thought is that Davis.js would catch the click and updates the hash if the browser doesn't support history state.

Is there a way to get Davis.js working to update only the hash or am I doing something wrong anyway? Is there any example somewhere to look that up?

@thasmo
Copy link
Author

thasmo commented Jun 25, 2013

If I use "forceHashRouting: true" the hash routing works well in IE10 (which actually supports history state), but IE < 10 (IE9, IE8) still don't work with hash routing. :(

@thasmo
Copy link
Author

thasmo commented Jun 25, 2013

Using "window.location.hash = 'foobar'" to update the hash works in IE < 10 and also triggers the correct route when using the hash routing plugin. Just when clicking on a link the hash doesn't get updated - instead it will load the requested path (pagereload) and then triggers the route.

@thasmo
Copy link
Author

thasmo commented Jul 10, 2013

I found the problem. It seems IE < 10 returns the hostname AND the port when using "elem.host". So the check return elem.host !== window.location.host will always fail. I've updated it to use return elem.host.split(':')[0] !== window.location.host which seems to work in IE8 and IE9; they both return hostname:80.

@rossthedevigner
Copy link

Thasmo,
So does Davis now fallback to the hash if the browser doesn't support the History API? Can you provide any more details as I'm looking at this same issue. Thanks!

@efreeti
Copy link

efreeti commented Mar 27, 2014

davis.hashRouting.js

@vasanthkumar258
Copy link

Hi everyone,

If i refresh the page, an extra # is included in the url and page is not getting rendered.
could anyone help me with hash routing in davis js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants