PageRenderTime 23ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/public/js/views/status_list.js

http://github.com/bkeepers/monologue
JavaScript | 28 lines | 17 code | 3 blank | 8 comment | 0 complexity | 2a97bfdaf617d767a3a21e49152fef0d MD5 | raw file
  1. // View to manage rendering of statuses
  2. //
  3. // Responsibility:
  4. // * Display list of statuses
  5. //
  6. // Dependencies:
  7. // * el - Element to contain the rendered statuses
  8. // * collection - a collection of statuses
  9. Monologue.View.StatusList = Backbone.View.extend({
  10. initialize: function() {
  11. _.bindAll(this, 'render', 'add');
  12. this.collection.on('reset', this.render);
  13. this.collection.on('add', this.add);
  14. this.collection.fetch();
  15. },
  16. render: function() {
  17. this.collection.each(_.bind(this.add, this));
  18. },
  19. add: function(model) {
  20. this.$el.append(this.template(model))
  21. },
  22. template: function(model) {
  23. return this.make('li', {'class':'status'}, model.get('text'));
  24. }
  25. });