Skip to content

Instantly share code, notes, and snippets.

@superlou
Created April 20, 2013 15:20
Show Gist options
  • Save superlou/5426325 to your computer and use it in GitHub Desktop.
Save superlou/5426325 to your computer and use it in GitHub Desktop.
<div class='update'>
<span class='created-at'>{{view.content.createdAt}}</span>
{{view Ember.TextArea valueBinding='view.content.details'}}
<a {{action deleteUpdate view.content}} href='#'>delete</button>
</div>
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