1 /** 2 * Application controller view 3 * Starts application, inits a new CommentCollection collection, assigns the empty list to 4 * a CommentlistView controller, also inits a NewButtonView instance to handle new comment insertion. 5 * 6 * Check index.html to find the place where App is initialized, it's right after the container 7 * DOM node is rendered. 8 * 9 * @class App 10 * @extends Backbone.View 11 * @author Bodnar Istvan <istvan@gawker.com> 12 */ 13 /*global CommentCollection, CommentlistView, FormView, NewButtonView, RandomButtonView */ 14 var App = Backbone.View.extend( 15 /** @lends App.prototype */ 16 { 17 /** 18 * Initialize new application instance 19 */ 20 initialize: function () { 21 // create empty comment collection 22 var collection = new CommentCollection(); 23 24 // bind the NewButtonView to the already rendered 'newcomment' DOM element, we'll need to know the 25 // collection to work with so FormView can insert the new comment properly 26 new NewButtonView({collection: collection, el: this.$el.find('.newcomment')}); 27 28 // bind the RandomButtonView to the already rendered 'randomcomment' DOM element 29 new RandomButtonView({collection: collection, el: this.$el.find('.randomcomment')}); 30 31 // create comment list view, assign our empty collection 32 var listview = new CommentlistView({collection: collection, el: this.$el.find('.commentlist')}); 33 listview.render(); 34 } 35 } 36 ); 37 38 39 /** 40 * Documentation related comments 41 */ 42 /** 43 * @name Backbone 44 * @class Backbone 45 * Application is a Backbone based application 46 * @link http://documentcloud.github.com/backbone/ 47 */ 48 49 50 /** 51 * @name Backbone.Model 52 * @class Backbone.Model 53 * Backbone model superclass 54 * @link http://documentcloud.github.com/backbone/ 55 */ 56 57 /** 58 * @name Backbone.Collection 59 * @class Backbone.Collection 60 * Backbone collection superclass 61 * @link http://documentcloud.github.com/backbone/ 62 */ 63 64 /** 65 * @name Backbone.View 66 * @class Backbone.View 67 * By default all views extend Backbone.View 68 * @link http://documentcloud.github.com/backbone/ 69 */ 70 71