Create a gist now

Instantly share code, notes, and snippets.

Backbone render
{{#if songs.length }}
{{#each songs}}
<tr><td>{{ }}</td><td>{{ this.duration }}</td></tr>
$ ->
class Song extends Backbone.Model
parse: (response) ->
console.log "model parsing #{response}"
class Songs extends Backbone.Collection
initialize: ->
@model = Song
@url = "/songs/data"
parse: (response) ->
console.log "collection parsing"
console.log response
songs = new Songs
class SongsView extends Backbone.View
initialize: ->
@model = Song
console.log "initializing SongsView"
console.log @collection
@collection.bind("reset", @render)
render: =>
console.log "render"
console.log @collection
template = Handlebars.compile(SONG_TEMPLATE)
@template = template(songs: @collection.toJSON())
console.log "template: #{@template}"
$('#song-list').html @template
songView = new SongsView(collection: songs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment