问题
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