lundi 29 juin 2015

Ember.js working with async relationship inside the controller

I have 2 models:

App.Center = DS.Model.extend({
    name: DS.attr('string'),
    code: DS.attr('string'),
    studies: DS.hasMany('study', {async: true})
});

App.Study = DS.Model.extend({
    center: DS.belongsTo('center'),
    //other data
});

In theory, Ember will wait for the studies promise to be resolved and then render the template to display them. For the common scenarios this is very good.

I must implement some filtering and other operations on the Center's studies inside the CenterStudiesController.

The problem is that center.get('studies') is an empty array inside the controller. How could I wait for them to be loaded?

I don't want to modify the server code in order to sideload the studies.

Is there a way to do this?




Aucun commentaire:

Enregistrer un commentaire