This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -# app/views/albums/index.html.haml | |
| .featured-albums.panel | |
| %ul#featured |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App.Views.AlbumItemView = Backbone.View.extend | |
| tagName: 'li' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App.Views.AlbumItemView = Backbone.View.extend | |
| tagName: 'li' | |
| template: _.template "<%= title %>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = new App.Views.AlbumItemView | |
| // child {cid: "view10", $el: jQuery.fn.init[1], el: li, model: child, constructor: function…} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App.Views.AlbumsItemView = Backbone.View.extend | |
| el: '#featured’ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ -> | |
| App.albumsListView = new App.Views.AlbumsListView | |
| App.albums = new App.Collections.Albums | |
| App.albums.fetch() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log(App.albums); | |
| // child {length: 9, models: Array[9], _byId: Object, constructor: function, model: function…} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| $ -> |