I have a simple ember-data model called a Task. When I route to /tasks, I can iterate over each task to create a list of all the tasks via my TasksController, template, and autogenerated view:
{{#each task in filteredContent}}
{{ partial "taskItem" }}
{{/each}}
filteredContent is a property watching the content and a filter criteria to provide a subset of App.Task.find().
This works well, but now I'd like to add more functionality to my tasks list, namely drag-and-drop sorting via jQuery's sortable plugin. Since I'd like to encapsulate the logic for displaying the tasks, I created a TasksListController:
App.TasksListController = Ember.ArrayController.extend {
needs: ['tasks']
contentBinding: 'controllers.tasks.filteredContent'
}
a TasksListView:
App.TasksListView = Ember.CollectionView.extend {
tagName: 'ul'
classNames: ['tasks-list']
itemViewClass: App.TasksListItemView
didInsertElement: ->
this._super();
this.$().sortable().disableSelection();
}
and a TasksListItemView:
App.TasksListItemView = Ember.View.extend {
templateName: 'tasks-list-item'
classNames: ['task-item']
}
If I insert console.log this.get 'controller.firstObject' in the didInsertElement method, the output is correct, but {{render tasks-list}} in the Tasks template (operating under the TasksController if I understand things correctly) always seems like there is no content. I've come across a few examples using CollectionView, but they seem to be pre-RC1, and suggest doing something like {{view 'App.TasksListView' contentBinding=filteredContent'}} (which doesn't seem to work either).
In this situation, is the render or view helper the appropriate way to go? Is this the right way to approach this problem, or is there a better Ember pattern to follow?
I am using Ember.js RC2 and ember-data DS.FixtureAdapter (revision 12). A simplified fiddle is available at http://jsfiddle.net/superlou/sUUXj/.