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

initial handler fired twice #227

Open
sulram opened this issue Mar 20, 2014 · 3 comments
Open

initial handler fired twice #227

sulram opened this issue Mar 20, 2014 · 3 comments

Comments

@sulram
Copy link

sulram commented Mar 20, 2014

Hello there!

I've created an strategy to always redirect users to home, and them open the desired uri via ajax and director.

When users try entering example.com/page1, they are redirected to example.com/#/page1.

I'm using pushState and director automatically corrects the route, removing the hash. That's cool!

The problem: sometimes director fires the route callback twice.

Why is that?

@beaugunderson
Copy link
Contributor

Glad to try and debug this if you can provide a small test that shows the incorrect behavior! :)

@sulram
Copy link
Author

sulram commented Jul 8, 2014

hi @beaugunderson
I notice that there was a little info in init method

        // There is an old bug in Chrome that causes onpopstate to fire even
        // upon initial page load. Since the handler is run manually in init(),
        // this would cause Chrome to run it twise. Currently the only
        // workaround seems to be to set the handler after the initial page load
        // http://code.google.com/p/chromium/issues/detail?id=63040

I solved the bug in SAFARI and SAFARI IOS by calling init after window.onload
What do you think about this?
thanks!

@cmwelsh
Copy link

cmwelsh commented Jan 22, 2015

I think the only robust solution is to refuse firing the same route twice in a row. The router instance should track the current route.

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

3 participants