Reputation: 19433
I'm using RouterJs to handle my history push state routes. How can I trigger the initial route if the user visits the route directly in their browser?
The route handler gets executed if I do router.navigate('/some-route')
from another route, but if I visit /some-route
directly, the handler for that route does not execute.
My JS:
var router = new Router();
router.route('/some-route', function () {
console.log('hello some route');
});
If I load the page directly to /some-route
and have my console open, I am not seeing "hello some route". I've tried doing router.navigate(window.location.pathname)
but router won't do anything b/c it's not a change in the url, i.e., I'm already on window.location.pathname
.
Upvotes: 1
Views: 53