Join Kai Gittens for an in-depth discussion in this video Creating a collection view, part of Up and Running with Backbone.js.
- View Offline
…With the single model view done, it's time to create the collection view.…The collection view syntax will be similar to the model view syntax,…although the property definitions will be different,…as will the render functionality.…We'll also be creating a custom function instead of…using one that comes with Backbone.…So, let's go back to snippets.txt.…And, I'm going to highlight and copy the lines 75 through 84, copy those,…and go back to allFlowersView.js, and paste them at the top.…
Again, my code gets namespace on line two, and…on line four I'm creating a variable called app.FlowersView, and…using it to create a brand new view with, backbone.view.extend.…I wanted to find a tag name for this so back to snippets.txt, scroll…down a little bit, copy the code that's on line 90, highlight it and copy it.…Back to allFlowersView, and…I'm going to paste this code inside of my allFlowers object.…
Here we go.…So the collection needs a web page element assigned to it.…This collection element will eventually contain all the tags I've defined in my…
- What is Backbone.js?
- Understanding how MVC libraries work
- Adding properties to a model
- Creating a collection of models
- Adding properties to a model view
- Loading model data on a web page
- Configuring routes
- Finding Backbone resources