Created
April 20, 2013 15:20
-
-
Save superlou/5426325 to your computer and use it in GitHub Desktop.
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
App.TaskUpdatesController = Ember.ArrayController.extend { | |
needs: ['task'] | |
taskBinding: 'controllers.task.model' | |
sortProperties: ['createdAt'] | |
sortAscending: false | |
newUpdateDetails: "" | |
createUpdate: -> | |
transaction = @store.transaction() | |
transaction.add @get('task') | |
newRecord = transaction.createRecord(App.Update, { | |
details: @get('newUpdateDetails') | |
task: @get('task') | |
createdAt: new Date() | |
}) | |
@set('newUpdateDetails', '') | |
transaction.commit() | |
deleteUpdate: (model) -> | |
model.deleteRecord() | |
model.get('transaction').commit() | |
} | |
App.TaskUpdatesView = Ember.View.extend { | |
templateName: 'task-updates' | |
} | |
App.TaskUpdatesListView = Ember.CollectionView.extend { | |
classNames: ['task-updates'] | |
contentBinding: 'controller' | |
itemViewClass: Ember.View.extend({ | |
templateName: 'task-updates-item' | |
didInsertElement: -> | |
$('.updates textarea').autosize({append: "\n"}) | |
# Hack to not transition textarea height on creation | |
setTimeout -> | |
$('.updates textarea').addClass('transition') | |
, 1000 | |
this._super() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment