I'm trying to pick up Backbone.js and one of the issues I'm trying to work through is how people use controllers effectively in Backbone.
I noticed that controllers were added later in the framework, and that views have a significant amount of controller logic just because of the way the browser and DOM are set up. Also the TODO list example on Backbone's website is implemented without a controller.
So I'm just unclear on how to use the controller aspect of backbone. If anyone could shed some light on this topic I'd really appreciate it.
Thanks! Matt
The difference between a Backbone.View and a Backbone.Controller is that the Controller has the routes architecture, and the corresponding Backbone.History() listener, which pays attention to the part of the URL after the hash tag (#).
Fundamentally, this means that a Backbone.Controller provides bookmarkable URLs. Because you can hand-write the hash portion, and bookmark them, the Bookmark.Controller should only refer to objects for which it makes sense to display a GETtable item.
I've written a little tutorial, http://www.elfsternberg.com/2010/12/08/backbonejs-introducing-backbone-store/, a port of the Sammy tutorial of The Backbone Store. If you follow the link to the GitHub repository, you can also get the latest version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With