visionmedia / page.js

Micro client-side router inspired by the Express router
http://visionmedia.github.com/page.js
7.67k stars 687 forks source link

Multiple pushstate in same url #417

Open aldebaran798 opened 7 years ago

aldebaran798 commented 7 years ago

Is it possible to prevent pushstate from a URL in a link if the URL is the same as the current one? For example, if I have a link that sends to a contact page, each time I press the link, the URL is always entered in the history, and when I want to go back, I have to press the button the same number of times I pressed the link

eth0lo commented 7 years ago

That's how should work, however sometimes is not the wanted behaviour.

What you can do however is add a handler on that particular link to verify if you are in the same path, but in order to avoid page to kick in the router process you will need to add target="_self" to the href, and when you are not do page.show(e.target.href)

iandunn commented 6 years ago

If I understand that workaround correctly, it seems like the complexity it'd add to the code would outweigh the benefit, at least in my project.

@tj, would you be interested in a PR that would add a config flag or some other simple way for users to determine how page.js behaves in this situation? Or do you prefer to just leave it the way it is?