Skip to content

Instantly share code, notes, and snippets.

@thenickcox
Last active August 29, 2015 14:11
Show Gist options
  • Save thenickcox/a08b567e32aa119c8618 to your computer and use it in GitHub Desktop.
Save thenickcox/a08b567e32aa119c8618 to your computer and use it in GitHub Desktop.
# app/assets/javascripts/views/albums_list_view.js.coffee
App.Views.AlbumsListView = Backbone.View.extend
el: '#featured'
initialize: ->
@listenTo @collection, 'sync', @render
@on 'handlePlaceholder', @setPlaceholder, @
render: ->
for model in @collection.featured()
itemView = new App.Views.AlbumItemView(model: model, listView: this)
@$el.append itemView.render().el
setPlaceholder: ->
if @collection.featured().length is 0
$('.featured-albums').append('<p>No featured albums</p>')
else
$('.featured-albums').find('p').remove()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment