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

How to re-enter a route? #1954

Closed
justb opened this issue Sep 1, 2017 · 8 comments
Closed

How to re-enter a route? #1954

justb opened this issue Sep 1, 2017 · 8 comments
Labels
Type: Question For issues that are purely questions about Mithril, not necessarily bug reports or suggestions

Comments

@justb
Copy link

justb commented Sep 1, 2017

Just like "window.location.reload()" this function, but do not reload the resource.

@dead-claudia
Copy link
Member

Does m.route.set(m.route.get()) solve your problem?

@dead-claudia dead-claudia added the Type: Question For issues that are purely questions about Mithril, not necessarily bug reports or suggestions label Sep 1, 2017
@justb
Copy link
Author

justb commented Sep 1, 2017

First thank you for your answer, but it does not work and the page does not respond at all.
My first solution is to enter one other route and then get in it, but it changes history.state. The second is to recall the method that in oninit lifecycle.

@tivac
Copy link
Contributor

tivac commented Sep 1, 2017

Gross hack, but you could call the two other routes with m.route.set("...", null, { replace: true }) which will replace the history entry instead of adding a new one.

Docs on m.route.set's 3rd param

@justb
Copy link
Author

justb commented Sep 2, 2017

Thank you very much, this is indeed a viable way.

@tivac
Copy link
Contributor

tivac commented Sep 2, 2017

@justb "viable" is a... strong word 😓 Glad it's working for you though! An option to force re-match a route when calling m.route.set() doesn't seem outside the realm of possibility. Would be worth filing an issue about if this is functionality that you'd find useful!

@justb
Copy link
Author

justb commented Sep 2, 2017

😓My English is not very good, but i am working on it. Thank you!

@justb justb closed this as completed Sep 2, 2017
@tivac
Copy link
Contributor

tivac commented Sep 2, 2017

Oh sorry, your choice of words there was totally fine!

I was pointing out that my workaround is terrible and mithril should provide you a better option than calling m.route.set() twice with a weird-looking param!

@GCSBOSS
Copy link

GCSBOSS commented Apr 5, 2022

Isn't there still a better alternative to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question For issues that are purely questions about Mithril, not necessarily bug reports or suggestions
Projects
None yet
Development

No branches or pull requests

4 participants