Is there a way to trigger same location route in backbone.js, for example when location is /My/App/#/About
and user clicks again on anchor with the same route in order to refresh the page content.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
That way you can trigger a route manually.
Assuming you want to do this for more than just the About page, use:
Since the Backbone router looks for changes in the URL fragment you want to load, what worked for me is to navigate to '/' first without trigger, and then subsequently to the URL (fragment) you want to hit with the trigger. You could probably build this into the default router behavior pretty easily if you wanted.
e.g.
Thanks for the suggestion @eddywashere, truly awesome. I added a little edit to mine that checks if you're on the last (most currentl) url, and if so, loads that history. Pretty simple, thought it might help someone with the same issue.
Another option : you can add a parameter with a random value, so hash will be different for each call, even if you call the same page.