Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PeopleView = Backbone.View.extend({
  2.  
  3.     initialize: function (options) {
  4.         this.options = options;
  5.         this.counter = 0;
  6.         this.render();
  7.         this.listenTo(this.collection,'reset',this.render);
  8.         vent.on('person:search',this.search);
  9.     },
  10.  
  11.     render: function () {
  12.         this.$el.html('');
  13.         this.collection.sort();
  14.         this.collection.each(this.renderPerson, this);
  15.     },
  16.  
  17.     renderPerson: function (person) {
  18.         var self = this;
  19.         this.$el.append(new PersonView({
  20.             tagName: 'li',
  21.             id:'p-'+person.get('id'),
  22.             model: person,
  23.             labels:self.options.labels
  24.         }).el);
  25.     },
  26.  
  27.     animate: function(){
  28.         console.log(this.collection.length);
  29.  
  30.         this.$el.find('li').each(function(i) {
  31.             $(this).delay(300*i).fadeOut(10, function() {
  32.                 $(this).fadeIn(300);
  33.             });
  34.         });
  35.     },
  36.  
  37.     search: function(str) {
  38.  
  39.         console.log(this.collection + " hejhej");
  40.  
  41.     }
  42. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement