Skip to content

Instantly share code, notes, and snippets.

-# app/views/albums/index.html.haml
.featured-albums.panel
%ul#featured
App.Views.AlbumItemView = Backbone.View.extend
tagName: 'li'
App.Views.AlbumItemView = Backbone.View.extend
tagName: 'li'
template: _.template "<%= title %>"
App.Views.AlbumItemView = Backbone.View.extend
tagName: 'li'
template: _.template "<%= title %>"
initialize: ->
@model = new App.Models.Album (title: 'Giant Steps')
render: ->
@$el.html @template @model.attributes
this
a = new App.Views.AlbumItemView
// child {cid: "view10", $el: jQuery.fn.init[1], el: li, model: child, constructor: function…}
App.Views.AlbumsItemView = Backbone.View.extend
el: '#featured’
App.Views.AlbumsItemView = Backbone.View.extend
el: '#featured'
render: ->
for model in @collection.models
itemView = new App.ItemView(model: model)
@$el.append itemView.render().el
$ ->
App.albumsListView = new App.Views.AlbumsListView
App.albums = new App.Collections.Albums
App.albums.fetch()
console.log(App.albums);
// child {length: 9, models: Array[9], _byId: Object, constructor: function, model: function…}
App.AlbumsListView = Backbone.View.extend
el: '#featured'
initialize: ->
@listenTo @collection, 'sync', @render
render: ->
for model in @collection.models
itemView = new App.AlbumItemView(model: model)
@$el.append itemView.render().el
$ ->