

#Backbone js patterns how to#
Discover how to download and use Handlebars templates, and work with. Sorry for not going into more detail, but like Thomas Davis said, the questions were very vague. js is a templating language for JavaScript applications that can be used with Backbone.js.

This is what happens when you write var MyModel = . 'When working on a web application that involves a lot of JavaScript, one of the first things you learn is to stop tying your data to the DOM. Its quite possible that your front-end models will be simpler than the backend ones.īy using backbone.js you are already using model inheritance. In my experience its wasn't necessary to replicate the backend data model in javascript. What you do with them and how you interact is up to you. Whats your question? The backbone doc says "it's highly recommended to include json2.js"Īgain, whats your question? Backbone provides you structure to do your own thing, you have to implement the complexities yourselfĪgain, you are implementing the models. However, even when you are not using Backbone, we encourage you to use Underscore.js for your JavaScript projects. So if you want nested views, you can use template engine that supports partials(If i understand correctly what you mean by nested views). Backbone.js has a hard dependency on Underscore.js, and you are bound to use it if you are developing your applications with Backbone.js. A view as provided by backbone is nothing but a mechanism to get changes in corresponded model to your render code. A model that has a collection of models in itself satisfies most of the requirement of a nested model.Īs far as views go, you're basically in control how they get rendered. I haven't had to deal with a collection of collections yet though, so maybe you can avoid it by restructuring your "data model". How do you handle nested collections/views?Īfaik there is no "simple way" to handle nested collections and handling events that happen in a sub-collection. The code is well documented and is an excellent example of what modern JS code should be. My number one practice/recipe is to dive into the backbone.js code and read it, step through it with js debugger even. Here is a list of questions you seem to have asked:
