我有一个容器视图其中包含一个集合视图。在这之后集合视图呈现在屏幕上我需要执行jquery函数它本质上是查看渲染模板的内容并执行一些显示修改。
如果我在插入元素 of 集合视图它可以工作,但它会针对中的每个元素执行集合视图因为我真的只需要在最后完成一次。我该如何指定呢?
http://jsfiddle.net/JFqNr/(注意不会在 jsfiddle 或某些原因上渲染,只是为了向您展示结构)
App = Ember.Application.create();
App.FooContainerView = Ember.ContainerView.extend({
childViews: ['elementList'],
elementList: Ember.CollectionView.extend({
content: function() {
return [
{ Title: "Dashboard", ID: "dashboard" },
{ Title: "Invoices", ID: "invoices" },
{ Title: "Expenses", ID: "expenses" },
{ Title: "People", ID: "people" },
{ Title: "Reports", ID: "reports" },
{ Title: "Settings", ID: "settings" }
];
}.property(),
template: Ember.Handlebars.compile( '{{view.content.title}}' ),
didInsertElement: function() {
// perform jquery function
}
}),
didInsertElement: function() {
// does not work if perforemed here
}
});
App.initialize();