Skip to content

Instantly share code, notes, and snippets.

@bkeepers
Created February 24, 2012 15:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkeepers/1901470 to your computer and use it in GitHub Desktop.
Save bkeepers/1901470 to your computer and use it in GitHub Desktop.
Spine Collections
class Message extends Spine.Model
@configure 'Message', 'text'
class Mentions extends Spine.Collection
@configure Message
@extend Spine.Model.Ajax
@url: '/messages/mentions'
class Search extends Spine.Collection
@configure Message
@extend Spine.Model.Ajax
@url: '/search'
class SearchController extends Spine.Controller
elements:
'text[type=search]': 'q'
events:
'submit form': 'search'
constructor: ->
Search.bind 'refresh', @render
search: (e) =>
e.preventDefault()
@search = new Search()
@search.fetch(q: @q.val())
Message.all()
render: =>
@replace @template(@search.all())
class MentionsController extends Spine.Controller
constructor: ->
Mentions.bind 'refresh', @render
@mentions = new Mentions()
@mentions.fetch()
render: ->
@append @template(@mentions.all())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment