Skip to content

Instantly share code, notes, and snippets.

@raytiley
Last active December 15, 2015 09:19
Show Gist options
  • Save raytiley/5237901 to your computer and use it in GitHub Desktop.
Save raytiley/5237901 to your computer and use it in GitHub Desktop.
Trying to figure out how I can run the same code that is in didInsertElement when items are added or removed from the sortedDocuments use in the #each helper.
<script type="text/x-handlebars" data-template-name="category">
<h3>{{ name }}</h3>
{{#view App.SortableContainer }}
{{#each sortedDocuments itemController="document"}}
<li {{bindAttr data-document-id="id" }}>
{{#if isEditing }}
{{view App.InlineDocumentEditView valueBinding="name" }}
{{else}}
<label {{ action editDocument on="doubleClick" }}>{{ name }}</label>
<a {{bindAttr href="url"}}>download</a>
{{/if}}
</li>
{{/each}}
{{/view}}
</script>
App.SortableContainer = Ember.View.extend({
tagName: 'ul',
didInsertElement: function() {
Ember.run.next(this, function() {
$(this.get('element')).sortable();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment