Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
47 lines (34 sloc) 0.939 kb
Spine = require('spine')
Contact = require('models/contact')
$ = Spine.$
class Sidebar extends Spine.Controller
className: 'sidebar'
elements:
'.items': 'items'
'input': 'search'
events:
'keyup input': 'filter'
'click footer button': 'create'
constructor: ->
super
@html require('views/sidebar')()
@list = new Spine.List
el: @items,
template: require('views/item'),
selectFirst: true
@list.bind 'change', @change
@active (params) ->
@list.change(Contact.find(params.id))
Contact.bind('refresh change', @render)
filter: ->
@query = @search.val()
@render()
render: =>
contacts = Contact.filter(@query)
@list.render(contacts)
change: (item) =>
@navigate '/contacts', item.id
create: ->
item = Contact.create()
@navigate('/contacts', item.id, 'edit')
module.exports = Sidebar
Jump to Line
Something went wrong with that request. Please try again.