app/assets/javascripts/backbone/views/contacts/contacts_list.js.coffee
b27f285a
 Xmpp.Views.Contacts ||= {}
 
 class Xmpp.Views.Contacts.ListView extends Backbone.View
   template: JST["backbone/templates/contacts/contact_list"]
 
   initialize: () ->
     _.bindAll(this)
 
     @el = '#' + @attributes['id']
619ceb7d
     @title = I18n.t(@attributes['title'])
b27f285a
 
52ef7688
     @contactViews = []
b27f285a
 
52ef7688
     @createListContainer()
b27f285a
 
52ef7688
   createListContainer: ->
     $(@el).html(@template(title: @title))
b27f285a
 
52ef7688
   appendContact: (contact) ->
     view =  new Xmpp.Views.Contacts.ContactView(model: contact, attributes: {listView: this})
     @contactViews.push view
     @render(view.render().el)
 
   render: (contactHtml) ->
     if (contactHtml?)
       $(@el).find('ul').append(contactHtml)
     else
       _.each(@contactViews, (i, contact) =>
         @render(contact.render().el)
       )
 
     return this