Reputation: 11663
Trying to learn backbone. In several applications that I've looked at (here is one http://blog.viison.com/post/11097185009/how-to-switch-views-using-backbonejs ), the author of the app or demo app initializes the ApplicationRouter in the index.html file, while all of the other javascript is in a JavaScript folder. What is it about the application router that makes it necessary to initialize in an html file?
<script type="text/javascript">
var router = new ApplicationRouter($('#content'));
Backbone.history.start();
</script>
Upvotes: 0
Views: 112
Reputation: 370
There's no requirement to do it inside the html. The author could be doing it there for ease of illustration. You could ask... the author has comments enabled on the blog post.
I've not seen it initiated in the html too often. Something like Backbone Boilerplate would be a good example of not initializing the router in the html.
https://github.com/tbranyen/backbone-boilerplate
Upvotes: 2