编辑:问题被撤销。CollectionViews 作为 ContentViews 的子类,不尊重布局,令人沮丧。
CollectionViews 似乎不适用于布局。例如:
测试用例:http: //jsfiddle.net/73sWp/
模板:
<script type="text/x-handlebars" data-template-name="layoutTest">
<div class="my-collection">
<h1>{{title}}</h1>
{{yield}}
</div>
</script>
<script type="text/x-handlebars" data-template-name="layoutTest-child">
<div class="an-item">
Hi there.
</div>
</script>
脚本:
var TestView = Ember.CollectionView.extend({
layoutName: "layoutTest",
title: "My Collection",
childViews: [
Ember.View.create({
templateName: 'layoutTest-child'
}),
Ember.View.create({
templateName: 'layoutTest-child'
})
]
});
$(function () {
TestView.create().appendTo(document.body);
});
预期的:
<div class="my-collection">
<h1>My Collection</h1>
<div class="an-item">
Hi there.
</div>
<div class="an-item">
Hi there.
</div>
</div>
实际的:
<div class="an-item">
Hi there.
</div>
<div class="an-item">
Hi there.
</div>
我错过了一些明显的东西吗?