How to catch whether array was inserted in handlebar in Ember?

℡╲_俬逩灬. 提交于 2019-12-23 21:28:01

问题


I hope this is not duplicate question, but I am not able to find solution...

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")
});

I am inserting data in user_dashboard.handlebar:

 {{#each job in jobs}}
      <li>
         {{job.shortDescription}}<br />
         {{job.startsAt}}</li>
    {{/each}}

This is my route:

JP.DashboardRoute = Ember.Route.extend({
    setupController: function(controller, model) {
        controller.set('users',  JP.User.find());
 }
});

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...


回答1:


You want to use the afterRender queue, check out Run jquery at the end of Ember.CollectionView rendering for a duplicate question



来源:https://stackoverflow.com/questions/15874812/how-to-catch-whether-array-was-inserted-in-handlebar-in-ember

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!