Created
February 24, 2012 15:01
-
-
Save bkeepers/1901470 to your computer and use it in GitHub Desktop.
Spine Collections
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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