Reputation: 758
I'am trying to use Em.CollectionView
to render ArrayController
. Problem that 'itemView' used to render each item has wierd render context (I expected that item will be used as context). But It's not.
Here is my templates. Index template:
{{view Ember.CollectionView content=controller itemViewClass="color"}}
Color template:
<b>content:</b>{{content}} </br>
<b>this:</b>{{this}} </br></br>
Here is model router and controller:
App.IndexRoute = Ember.Route.extend({
model: function() {
return ['red', 'yellow', 'blue'];
}
});
App.IndexController = Ember.ArrayController.extend({
itemController: 'color'
});
And result is:
content:red,yellow,blue this:<App.IndexController:ember209>
content:red,yellow,blue this:<App.IndexController:ember209>
content:red,yellow,blue this:<App.IndexController:ember209>
Full example -- http://emberjs.jsbin.com/aZiciYOc/4/edit How to set item controller properly?
Upvotes: 0
Views: 159
Reputation: 19128
If you use:
{{each controller itemView="color"}}
Instead of:
{{view Ember.CollectionView content=controller itemViewClass="color"}}
will work.
http://emberjs.jsbin.com/aZiciYOc/8/edit
Upvotes: 2
Reputation: 336
Try this:
<script type="text/x-handlebars" data-template-name="color">
<b>content:</b>{{view.content.model}} </br>
<b>this:</b>{{this}} </br></br>
</script>
Difference is in second line
Upvotes: 0