我有一些观点,与他们各自的模型密切相关:
image.handlerbars:
URL:{{view Ember.TextField
valueBinding="EvEditor.imageModel.imgUrl"
}}<br/>
text.handlerbars:
{{view Ember.TextField
valueBinding="EvEditor.titleModel.text"
}}<br/>
我现在想创建一个包含许多图像和文本块的复合视图:
var container = Ember.ContainerView.create({
childViews: ['firstView', 'secondView', 'thirdView', 'fourthView'],
firstView: App.TextView,
secondView: App.TextView,
thirdView: App.ImageView,
fourthView: App.ImageView
});
现在,就目前而言,每个 ImageView 和 TextView 都将包含相同的数据,而不是为每个分配不同的 ImageModel / TextView 实例。
构建这种东西的最佳方法是什么?我真的不希望创建视图的代码也必须知道需要将哪些属性传递到每个视图中,例如,是吗?
理想情况下,我会编写类似这样的伪代码:
var container = Ember.ContainerView.create({
childViews: ['firstView', 'secondView', 'thirdView', 'fourthView'],
firstView: {view=App.TextView, model=App.EmberObjectincomingData[0]},
secondView: {view=App.TextView, model=App.EmberObjectincomingData[1]},
thirdView: {view=App.ImageView, model=App.EmberObjectincomingData[2]},
fourthView: {view=App.ImageView model=App.EmberObjectincomingData[3]},
});