Created
March 23, 2013 04:25
-
-
Save raytiley/5226444 to your computer and use it in GitHub Desktop.
Creating a sortable view using the html5sortable plugin and emberjs
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
// Working on getting html5sortable plugin working | |
// Key part is needing to call the sortable() method using Ember.run.next | |
// If called straight away the functionality quickly gets applied, but then is lost | |
// At least that's what it looks like when stepping through chrome debugger | |
// http://farhadi.ir/projects/html5sortable/ | |
App.SortableView = Ember.CollectionView.extend({ | |
tagName: 'ul', | |
itemViewClass: 'App.SortableItemView', | |
didInsertElement: function(){ | |
var view = this; | |
Ember.run.next(function() { | |
$(view.get('element')).sortable(); | |
}); | |
} | |
}); | |
App.SortableItemView = Ember.View.extend({ | |
templateName: 'sortable-item' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment