Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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"
window.songs = new Songs
class SongsView extends Backbone.View
initialize: ->
@el = 'body'
@model = Song
@collection.bind("reset", @render)
@events = {'click button': 'zeep'}
render: (arg) =>
console.log "render"
console.log @collection
template = Handlebars.compile(SONG_TEMPLATE)
@template = template(songs: @collection.toJSON())
console.log "template: #{@template}"
$('#song-list').html @template
zeep: =>
console.log 'zeep!'
window.songView = new SongsView(collection: window.songs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment