I would like to have several routers living on the same page for modularity. I initialize routers on $(document).ready()in different js files. When I had only one router that worked fine, because I could call History.start()right after the router was initialized, but now that I have several routers that can be initialized from different files, I'm not sure when to call History.start().
For instance:
<script src="router1.js" type="text/javascript"></script>
<script src="router2.js" type="text/javascript"></script>
In router1.js:
$(document).ready(function(){
new Core.Routers.Router1()
});
as well as for the router 2.
Is the best solution to add a new $(document).ready()one that calls History.start()at the end of the page? I do not think that ready-made doc calls are blocked, so this does not mean that the race condition in which all routers were not initialized by the time History.start().
source
share