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

Add replaceState support #84

Open
ralphsmith80 opened this issue May 14, 2015 · 0 comments
Open

Add replaceState support #84

ralphsmith80 opened this issue May 14, 2015 · 0 comments

Comments

@ralphsmith80
Copy link

I'm using a setTimeout in .to so the path will resolve before forwarding to another route. This maybe the reason the add delay() issue was filed since that's what I started investigating before I realized the behavior I want to achieve is supported by IE10+ browsers with history.replaceState.

Example:

Path.map('/app').to(function() {
  // timeout is set so that the `history.pushState` happens before we navigate to the route we want
  // to redirect to https://github.com/mtrpcic/pathjs/blob/master/path.js#L21
  setTimeout(function() {
    var id = '1234';
    Path.history.pushState({}, null, '/app/'+id);
  }, 0);
});
Path.map('/app/:id').to(function() {
  // do stuff with a view that require an id, i.e. this.params.id
});

Using the setTimeout is functionally correct but if I use the back button I would go back to /app which would just forward me back to /app/1234. If I use replaceState then I replace history with the correct url so the back button functions how a user would expect it to.

Basically a redirect that is opaque to the user so we shouldn't keep that in history. i.e. use history.replaceState.

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

1 participant