I am currently working on an Ember.js (1.0.0) Application where I'm incorporating the Ember.Select
view to display three task lists: inProgress
, completed
, and unassigned
. Users have the ability to filter tasks based on their project. However, upon loading the route, I encounter errors from Ember about the type of value being passed:
Assertion failed: The value that #each loops over must be an Array. You passed projects.all
Uncaught TypeError: Object projects.all has no method 'addArrayObserver'
Uncaught Error: Something you did caused a view to re-render after it rendered but before it was inserted into the DOM.
I've spent considerable time trying different variations of the code below - there's definitely something simple that I seem to be missing. It can't possibly be this challenging to make such a basic component work correctly. Your guidance in setting me on the right path would be greatly appreciated.
As defined in my Route:
Bee.TasksIndexRoute = Bee.Auth.Route.extend
setupController: (ctrl) ->
# fetching tasks
Bee.Auth.send
url: Bee.endpoint "/tasks"
.done (tasks) ->
ctrl.set "tasks.all", tasks
# fetching projects
Bee.Auth.send
url: Bee.endpoint "/projects"
.done (projects) ->
ctrl.set "projects.owned", projects.owned
ctrl.set "projects.participating", projects.participating
ctrl.set "projects.all", projects.owned.concat projects.participating
In my Controller:
Bee.TasksIndexController = Ember.ObjectController.extend
project: null
content:
tasks:
all: []
inProgress: []
completed: []
unassgined: []
projects:
all: []
owned: []
participating: []
visible: (->
ctrl = @
# filtering tasks
).property "project"
The Template structure:
<script type="text/x-handlebars" id="tasks/index">
<div class="center-pane">
<div class="top_options">
<div class="project_filter">
<strong>Viewing: </strong>
{{view Ember.Select
content=projects.all
optionValuePath='content._id'
optionLabelPath='content.title'
value=project
prompt='All Tasks'
}}
</div>
<strong class="gold-gradient option_button">
{{#link-to 'tasks.create' classNames='new_task'}}Create Task{{/link-to}}
</strong>
</div>
<div class="col3">
<div class="col-header in-progress light-gradient">
<h3>In Progress</h3>
</div>
<div id="tasks_active_list">
{{#if visible.inProgress.length}}
<ul>{{#each visible.inProgress}}{{view Bee.TaskListView}}{{/each}}</ul>
{{else}}
<p class="no_projects">None</p>
{{/if}}
</div>
</div>
<div class="col3">
<div class="col-header completed light-gradient">
<h3>Completed</h3>
</div>
<div id="tasks_closed_list">
{{#if visible.completed.length}}
<ul>{{#each visible.completed}}{{view Bee.TaskListView}}{{/each}}</ul>
{{else}}
<p class="no_projects">None</p>
{{/if}}
</div>
</div>
<div class="col3">
<div class="col-header unassigned light-gradient">
<h3>Unassigned</h3>
</div>
<div id="tasks_unassigned_list">
{{#if visible.unassigned.length}}
<ul>{{#each visible.unassigned}}{{view Bee.TaskListView}}{{/each}}</ul>
{{else}}
<p class="no_projects">None</p>
{{/if}}
</div>
</div>
</div>
</script>
Your insights would be invaluable. I understand that the issue lies with Ember.Select
, as using a straightforward <select>
works fine. However, I need to utilize Ember.Select
for binding the value to the project
property on the TasksIndexController
to trigger the visible
function.