Created
October 23, 2013 22:20
-
-
Save bhserna/7127803 to your computer and use it in GitHub Desktop.
emberjs vs frontend hacks --- emberjs
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.QuestionController = Ember.ObjectController.extend | |
| createAnswer: -> | |
| body = @get 'newAnswerBody' | |
| return if !body.trim() | |
| question = @get 'model' | |
| answer = App.Answer.createRecord question: question, body: body | |
| @set 'newAnswerBody', '' | |
| @get('store').commit() |
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.User = DS.Model.extend | |
| questions: DS.hasMany("App.Question") | |
| questionsToAnswer: (-> | |
| @get('questions').filterProperty('hasAnswer', false) | |
| ).property('[email protected]') | |
| questionsToAnswerCount: (-> | |
| @get("questionsToAnswer").get('length') | |
| ).property('questionsToAnswer') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment