Created
January 10, 2013 07:31
-
-
Save leepfrog/4500204 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| App.BookIndexController = Ember.ArrayController.extend | |
| content: [] # array of books | |
| proxies: {} # proxy cache for books | |
| # Creates and caches a proxy that will wrap around our book | |
| createProxy: (book, id) -> | |
| @proxies[id] = BookProxy.create | |
| content: book | |
| controller: this | |
| # This wraps each book in our book array w/ a proxy | |
| objectAtContent: (index) -> | |
| book = @get('arrangedContent').objectAt(index) | |
| if book? | |
| book_id = book.get('id') | |
| if @proxies[book_id] then @proxies[book_id] else @createProxy(book,book_id) | |
| BookProxy = Em.ObjectProxy.extend | |
| isSelected: (-> | |
| @get('controller.selectedBook') == @get('content') | |
| ).property('controller.selectedBook') | |
| # Other stuff goes here for augmenting the book model / behavior |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment