Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. var TodoList = Backbone.Collection.extend({
  2.  
  3. model: Todo,
  4.  
  5. comparator: function(todo) {
  6. return todo.get('title');
  7. }
  8.  
  9. });
  10.  
  11. var TodoView = Backbone.View.extend({
  12.  
  13. tagName: "li",
  14.  
  15. template: _.template($('#item-template').html()),
  16.  
  17. initialize: function() {
  18. this.listenTo(this.model, 'change', this.render);
  19. this.listenTo(this.model, 'destroy', this.remove);
  20. },
  21.  
  22. render: function() {
  23. this.$el.html(this.template(this.model.toJSON()));
  24. this.$el.toggleClass('done', this.model.get('done'));
  25. this.input = this.$('.edit');
  26. return this;
  27. }
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement