如何从容器初始化函数中访问索引路径模型钩子中定义的模型我希望容器迭代模型并为模型数组中的每个对象创建子视图? 这是代码示例:
App= Ember.Application.create();
App.Router.map(function(){
})
App.IndexRoute=Ember.Route.extend({
model: function(){
return arr;
}
})
App.MainView = Em.View.extend({
classNames: ['mainView']
});
App.MyContainerView = Em.ContainerView.extend({
tagName:"tbody",
});
var container = App.MyContainerView.create({
init: function() {
//this._super();
//this.pushObject(App.FirstView.create());
//this.pushObject(App.SecondView.create());
}
});
App.SingleTaskView = Em.View.extend({
templateName:'single-task',
tagName:""
});
App.IndexController= Ember.ArrayController.extend({
actions: {
newTask: function(){
var containerView = Em.View.views['my_container_view']
var childView = containerView.createChildView(App.SingleTaskView);
containerView.get('childViews').pushObject(childView);
}
}
});