Skip to content

Instantly share code, notes, and snippets.

@raytiley
Created March 23, 2013 04:25
Show Gist options
  • Save raytiley/5226444 to your computer and use it in GitHub Desktop.
Save raytiley/5226444 to your computer and use it in GitHub Desktop.
Creating a sortable view using the html5sortable plugin and emberjs
// 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'
});
<script type="text/x-handlebars" data-template-name="sortable-item">
{{ view.content.name }}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment