Created
January 15, 2013 05:06
-
-
Save walter/4536276 to your computer and use it in GitHub Desktop.
Sortable CollectionView
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
Lm.PostsCollectionView = Em.CollectionView.extend | |
tagName: 'tbody' | |
didInsertElement: -> | |
# changes position property of fieldCategories accordingly | |
# and pushes changes to server with commit | |
@$().sortable | |
items: 'tr' | |
containment: @$() | |
stop: (evt, ui) -> | |
# TODO: would be nice to do this in a proper transaction | |
$.each $(this).sortable('toArray'), (idx, id)-> | |
post = Ember.View.views[id].get('content') | |
post.set('position', idx + 1) | |
post.get('store').commit() | |
itemViewClass: Em.View.extend | |
tagName: 'tr' | |
templateName: 'posts/collection_item' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment