问题描述
我希望这不是重复的问题,但我无法找到解决方案...
I hope this is not duplicate question, but I am not able to find solution...
我有工作和用户,一个用户有很多工作: / p>
I have Jobs and Users, one user has many jobs:
JP.User = DS.Model.extend({
firstName: DS.attr('string'),
lastName: DS.attr('string'),
email: DS.attr('string'),
jobs: DS.hasMany("JP.Job")
});
我在user_dashboard.handlebar中插入数据:
I am inserting data in user_dashboard.handlebar:
{{#each job in jobs}}
<li>
{{job.shortDescription}}<br />
{{job.startsAt}}</li>
{{/each}}
这是我的路线:
JP.DashboardRoute = Ember.Route.extend({
setupController: function(controller, model) {
controller.set('users', JP.User.find());
}
});
在将用户的所有作业插入句柄后,如何捕获事件?我尝试了不同的方式来捕获它( controller.jobs.isLoaded,content.isLoaded,didInsertElement
...),但它没有工作。
How can I catch event after all jobs for user are inserted into the handlebar? I have tried different ways to catch it (controller.jobs.isLoaded, content.isLoaded, didInsertElement
...), but it didn't work.
我可以尝试抓住每个工作的插入,但我认为必须有更好的方式来抓取插入工作...
I can try to catch insertion of each job, but I think there must be some better way to catch insertion of jobs...
推荐答案
您要使用 afterRender
队列,请查看在Ember.CollectionView渲染结束时运行jquery重复问题
You want to use the afterRender
queue, check out Run jquery at the end of Ember.CollectionView rendering for a duplicate question
这篇关于如何捕获数组是否插入到Ember的handlebar中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!