using back button does not re-trigger all my routes
newtonianb opened this issue · 0 comments
Situation: Loading the page from the URL
triggers all my routes and subroutes but accessing that URL after pressing the back or forward button only triggers the last subroute.
Problem
Let's say I access http://host/path1/path2/path3
from within he App I click on a link which brings me to http://host/otherpath
. When I press the back button it brings me back to http://host/path1/path2/path3
in the URL but only my ModuleThree.Router gets hit. I want all of them to get hit again, how can I do this?
- user loads url
http://host/path1/path2/path3
inside one
inside two
inside three
- user clicks on link that goes to
http://otherpath
- user presses back button
inside three
My problem is on step 3, I'm expecting all the subroutes to re-trigger for my app to function correctly but only the last sub-route is triggered.
Example: Below I setup my subrouters so when accessing
http://host/path1/path2/path3
I have 3 matches triggered total
/path1/*subroute
handled by ModuleOne.Router (initialized by appInitiliazer)
/path2/*subroute
handled by ModuleTwo.Router (initialized by ModuleOne.Router)
/path3/*subroute
handled by ModuleThree.Router (initialized by ModuleTwo.Router)
## ROUTER
class ModuleOne.Router extends App.Router
routes:
"path1/*subroute" : "pathOne"
pathOne: (hash) ->
console.log 'inside one'
## this gets triggered on URL enter if /path1 is in URL
new App.ModuleTwo.Router("path1")
new ModuleOne.Router
## -------------------------------------------------------
## ROUTER
class ModuleTwo.Router extends App.SubRouter
routes:
"path2/*subroute" : "pathTwo"
pathTwo: ->
console.log 'inside two'
new App.ModuleThree.Router("path1/path2")
## -------------------------------------------------------
## ROUTER
class ModuleThree.Router extends App.SubRouter
routes:
"path3/*subroute" : "pathThree"
pathThree: ->
console.log 'inside three'