script.coffee | |
|---|---|
Extending Backbone.View | |
| First, we'll extend Backbone.View to create a very minimal unordered list view. Take a look at the implementation of this step so you'll know what we're building. | |
| The | jQuery ->
|
| Our main application view. | class ListView extends Backbone.View
|
| We'll be using the | el: $ 'body'
|
|
| initialize: -> |
| We're using Underscore.js's bindAll method to bind all the view's methods to this instance of our view. | _.bindAll @
@render()
|
|
| render: ->
$(@el).append '<ul><li>Hello, Backbone!</li></ul>'
|
| Lastly, we instantiate our main app view. | list_view = new ListView |
| Onward to Part 2. | |