Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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